Skip to content

Commit 25e64ed

Browse files
committed
[IMP] account_reconcile_restrict_partner_mismatch: Avoid restriction on some journals / Enable on company level
In some cases, accounting users should be allowed to mix partners. This will be configured on account journal level. In order to not break standard behaviors, the restriction feature should be enabled by a configuration parameter on company level. A new configuration parameter has been added.
1 parent d79fd0d commit 25e64ed

File tree

12 files changed

+168
-31
lines changed

12 files changed

+168
-31
lines changed

account_reconcile_restrict_partner_mismatch/README.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Reconcile restrict partner mismatch
77
!! This file is generated by oca-gen-addon-readme !!
88
!! changes will be overwritten. !!
99
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10-
!! source digest: sha256:e643e776a13ac74578f05aa23fc0328120234f43ff74182e837e0d18e2f357ae
10+
!! source digest: sha256:893e295e519a93dd096174319fa89d25509ab7df53a313bf5cc93c2b98a6be42
1111
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1212
1313
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
@@ -39,11 +39,22 @@ As at the moment of installation some journal items could have been reconciled
3939
using different partners, you can detect them in menu Accounting > Adviser >
4040
Reconciled items with partner mismatch.
4141

42+
This restriction can be enabled per company but can also be deactivated per journal.
43+
4244
**Table of contents**
4345

4446
.. contents::
4547
:local:
4648

49+
Configuration
50+
=============
51+
52+
- Go to Accounting > Configuration > Settings > Partners Mismatch Restriction on Reconcile
53+
- Check the box to activate the parameter.
54+
- To deactivate the behavior on journal level, go to Accounting > Configuration > Accounting > Journals
55+
- In Advanced Settings > Partner Mismatch On Reconcile
56+
- Check the box if you want to deactivate the restriction for that journal entries.
57+
4758
Bug Tracker
4859
===========
4960

account_reconcile_restrict_partner_mismatch/__manifest__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
"website": "https://github.com/OCA/account-reconcile",
1212
"category": "Finance",
1313
"license": "AGPL-3",
14-
"data": ["report/account_move_lines_report.xml", "security/ir.model.access.csv"],
14+
"data": [
15+
"security/ir.model.access.csv",
16+
"report/account_move_lines_report.xml",
17+
"views/account_journal.xml",
18+
"views/res_config_settings.xml",
19+
],
1520
"installable": True,
1621
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
from . import account_move_line
2+
from . import account_journal
3+
from . import res_company
4+
from . import res_config_settings
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2024 ACSONE SA/NV
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
from odoo import fields, models
4+
5+
6+
class AccountJournal(models.Model):
7+
8+
_inherit = "account.journal"
9+
10+
no_restrict_partner_mismatch_on_reconcile = fields.Boolean(
11+
help="Check this if you don't want to restrict partner "
12+
"mismatch (several differents) on reconcile."
13+
)

account_reconcile_restrict_partner_mismatch/models/account_move_line.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,31 @@
33

44
from odoo import _, models
55
from odoo.exceptions import UserError
6-
from odoo.tools import config
76

87

98
class AccountMoveLine(models.Model):
109
_inherit = "account.move.line"
1110

12-
def reconcile(self):
13-
if config["test_enable"] and not self.env.context.get("test_partner_mismatch"):
14-
return super().reconcile()
11+
@property
12+
def _check_partner_mismatch_on_reconcile(self):
13+
"""
14+
Returns True if the partner mismatch check on reconcile should be done
15+
"""
16+
self.ensure_one()
17+
return bool(
18+
self.company_id.restrict_partner_mismatch_on_reconcile
19+
and not self.journal_id.no_restrict_partner_mismatch_on_reconcile
20+
and self.account_id.account_type
21+
in ("asset_receivable", "liability_payable")
22+
)
1523

24+
def reconcile(self):
1625
# to be consistent with parent method
1726
if not self:
1827
return True
1928
partners = set()
2029
for line in self:
21-
if line.account_id.account_type in (
22-
"asset_receivable",
23-
"liability_payable",
24-
):
30+
if line._check_partner_mismatch_on_reconcile:
2531
partners.add(line.partner_id.id)
2632
if len(partners) > 1:
2733
raise UserError(
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2024 ACSONE SA/NV
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
from odoo import fields, models
4+
5+
6+
class ResCompany(models.Model):
7+
8+
_inherit = "res.company"
9+
10+
restrict_partner_mismatch_on_reconcile = fields.Boolean(
11+
help="Check this if you want to avoid partner mismatch"
12+
" (several different partners) on reconciliation."
13+
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2024 ACSONE SA/NV
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
from odoo import fields, models
4+
5+
6+
class ResConfigSettings(models.TransientModel):
7+
8+
_inherit = "res.config.settings"
9+
10+
restrict_partner_mismatch_on_reconcile = fields.Boolean(
11+
related="company_id.restrict_partner_mismatch_on_reconcile",
12+
readonly=False,
13+
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- Go to Accounting > Configuration > Settings > Partners Mismatch Restriction on Reconcile
2+
- Check the box to activate the parameter.
3+
- To deactivate the behavior on journal level, go to Accounting > Configuration > Accounting > Journals
4+
- In Advanced Settings > Partner Mismatch On Reconcile
5+
- Check the box if you want to deactivate the restriction for that journal entries.

account_reconcile_restrict_partner_mismatch/readme/DESCRIPTION.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ This rule applies only for journal items using receivable and payable account ty
88
As at the moment of installation some journal items could have been reconciled
99
using different partners, you can detect them in menu Accounting > Adviser >
1010
Reconciled items with partner mismatch.
11+
12+
This restriction can be enabled per company but can also be deactivated per journal.

account_reconcile_restrict_partner_mismatch/static/description/index.html

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
21
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
32
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
43
<head>
54
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6-
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
5+
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
76
<title>Reconcile restrict partner mismatch</title>
87
<style type="text/css">
98

109
/*
1110
:Author: David Goodger (goodger@python.org)
12-
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
11+
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
1312
:Copyright: This stylesheet has been placed in the public domain.
1413
1514
Default cascading style sheet for the HTML output of Docutils.
15+
Despite the name, some widely supported CSS2 features are used.
1616
17-
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
17+
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
1818
customize this style sheet.
1919
*/
2020

@@ -275,7 +275,7 @@
275275
margin-left: 2em ;
276276
margin-right: 2em }
277277

278-
pre.code .ln { color: grey; } /* line numbers */
278+
pre.code .ln { color: gray; } /* line numbers */
279279
pre.code, code { background-color: #eeeeee }
280280
pre.code .comment, code .comment { color: #5C6576 }
281281
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -301,7 +301,7 @@
301301
span.pre {
302302
white-space: pre }
303303

304-
span.problematic {
304+
span.problematic, pre.problematic {
305305
color: red }
306306

307307
span.section-subtitle {
@@ -367,9 +367,9 @@ <h1 class="title">Reconcile restrict partner mismatch</h1>
367367
!! This file is generated by oca-gen-addon-readme !!
368368
!! changes will be overwritten. !!
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370-
!! source digest: sha256:e643e776a13ac74578f05aa23fc0328120234f43ff74182e837e0d18e2f357ae
370+
!! source digest: sha256:893e295e519a93dd096174319fa89d25509ab7df53a313bf5cc93c2b98a6be42
371371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/account-reconcile/tree/16.0/account_reconcile_restrict_partner_mismatch"><img alt="OCA/account-reconcile" src="https://img.shields.io/badge/github-OCA%2Faccount--reconcile-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-reconcile-16-0/account-reconcile-16-0-account_reconcile_restrict_partner_mismatch"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runboat.odoo-community.org/builds?repo=OCA/account-reconcile&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
372+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/account-reconcile/tree/16.0/account_reconcile_restrict_partner_mismatch"><img alt="OCA/account-reconcile" src="https://img.shields.io/badge/github-OCA%2Faccount--reconcile-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-reconcile-16-0/account-reconcile-16-0-account_reconcile_restrict_partner_mismatch"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/account-reconcile&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373373
<p>This module restricts reconciliation between journal items when:</p>
374374
<blockquote>
375375
<ul class="simple">
@@ -381,37 +381,49 @@ <h1 class="title">Reconcile restrict partner mismatch</h1>
381381
<p>As at the moment of installation some journal items could have been reconciled
382382
using different partners, you can detect them in menu Accounting &gt; Adviser &gt;
383383
Reconciled items with partner mismatch.</p>
384+
<p>This restriction can be enabled per company but can also be deactivated per journal.</p>
384385
<p><strong>Table of contents</strong></p>
385386
<div class="contents local topic" id="contents">
386387
<ul class="simple">
387-
<li><a class="reference internal" href="#bug-tracker" id="id1">Bug Tracker</a></li>
388-
<li><a class="reference internal" href="#credits" id="id2">Credits</a><ul>
389-
<li><a class="reference internal" href="#authors" id="id3">Authors</a></li>
390-
<li><a class="reference internal" href="#contributors" id="id4">Contributors</a></li>
391-
<li><a class="reference internal" href="#other-credits" id="id5">Other credits</a></li>
392-
<li><a class="reference internal" href="#maintainers" id="id6">Maintainers</a></li>
388+
<li><a class="reference internal" href="#configuration" id="toc-entry-1">Configuration</a></li>
389+
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-2">Bug Tracker</a></li>
390+
<li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a><ul>
391+
<li><a class="reference internal" href="#authors" id="toc-entry-4">Authors</a></li>
392+
<li><a class="reference internal" href="#contributors" id="toc-entry-5">Contributors</a></li>
393+
<li><a class="reference internal" href="#other-credits" id="toc-entry-6">Other credits</a></li>
394+
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
393395
</ul>
394396
</li>
395397
</ul>
396398
</div>
399+
<div class="section" id="configuration">
400+
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
401+
<ul class="simple">
402+
<li>Go to Accounting &gt; Configuration &gt; Settings &gt; Partners Mismatch Restriction on Reconcile</li>
403+
<li>Check the box to activate the parameter.</li>
404+
<li>To deactivate the behavior on journal level, go to Accounting &gt; Configuration &gt; Accounting &gt; Journals</li>
405+
<li>In Advanced Settings &gt; Partner Mismatch On Reconcile</li>
406+
<li>Check the box if you want to deactivate the restriction for that journal entries.</li>
407+
</ul>
408+
</div>
397409
<div class="section" id="bug-tracker">
398-
<h1><a class="toc-backref" href="#id1">Bug Tracker</a></h1>
410+
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
399411
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-reconcile/issues">GitHub Issues</a>.
400412
In case of trouble, please check there if your issue has already been reported.
401413
If you spotted it first, help us to smash it by providing a detailed and welcomed
402414
<a class="reference external" href="https://github.com/OCA/account-reconcile/issues/new?body=module:%20account_reconcile_restrict_partner_mismatch%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
403415
<p>Do not contact contributors directly about support or help with technical issues.</p>
404416
</div>
405417
<div class="section" id="credits">
406-
<h1><a class="toc-backref" href="#id2">Credits</a></h1>
418+
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
407419
<div class="section" id="authors">
408-
<h2><a class="toc-backref" href="#id3">Authors</a></h2>
420+
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
409421
<ul class="simple">
410422
<li>Camptocamp</li>
411423
</ul>
412424
</div>
413425
<div class="section" id="contributors">
414-
<h2><a class="toc-backref" href="#id4">Contributors</a></h2>
426+
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
415427
<ul class="simple">
416428
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:
417429
* Ernesto Tejeda</li>
@@ -422,13 +434,15 @@ <h2><a class="toc-backref" href="#id4">Contributors</a></h2>
422434
</ul>
423435
</div>
424436
<div class="section" id="other-credits">
425-
<h2><a class="toc-backref" href="#id5">Other credits</a></h2>
437+
<h2><a class="toc-backref" href="#toc-entry-6">Other credits</a></h2>
426438
<p>The migration of this module from 13.0 to 14.0 was financially supported by Camptocamp</p>
427439
</div>
428440
<div class="section" id="maintainers">
429-
<h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
441+
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
430442
<p>This module is maintained by the OCA.</p>
431-
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
443+
<a class="reference external image-reference" href="https://odoo-community.org">
444+
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
445+
</a>
432446
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
433447
mission is to support the collaborative development of Odoo features and
434448
promote its widespread use.</p>

0 commit comments

Comments
 (0)