diff --git a/account_reconcile_restrict_partner_mismatch/README.rst b/account_reconcile_restrict_partner_mismatch/README.rst index 8d2f43c86..39a8e1267 100644 --- a/account_reconcile_restrict_partner_mismatch/README.rst +++ b/account_reconcile_restrict_partner_mismatch/README.rst @@ -98,6 +98,7 @@ Other credits ------------- The migration of this module from 13.0 to 14.0 was financially supported +The migration of this module from 16.0 to 18.0 was financially supported by Camptocamp Maintainers diff --git a/account_reconcile_restrict_partner_mismatch/models/account_move_line.py b/account_reconcile_restrict_partner_mismatch/models/account_move_line.py index ae875e325..756fe6df7 100644 --- a/account_reconcile_restrict_partner_mismatch/models/account_move_line.py +++ b/account_reconcile_restrict_partner_mismatch/models/account_move_line.py @@ -1,7 +1,6 @@ # Copyright 2019 Camptocamp SA # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). - -from odoo import _, models +from odoo import models from odoo.exceptions import UserError @@ -21,18 +20,18 @@ def _check_partner_mismatch_on_reconcile(self): in ("asset_receivable", "liability_payable") ) - def reconcile(self): + def _reconcile_plan(self, reconciliation_plan): # to be consistent with parent method - if self: + if reconciliation_plan: partners = set() - for line in self: - if line._check_partner_mismatch_on_reconcile: - partners.add(line.partner_id.id) + for lines in reconciliation_plan: + checked_lines = lines.filtered(lambda l: l._check_partner_mismatch_on_reconcile) + partners.update(line.partner_id.id for line in checked_lines) if len(partners) > 1: raise UserError( - _( + self.env._( "The partner has to be the same on all" " lines for receivable and payable accounts!" ) ) - return super().reconcile() + return super()._reconcile_plan(reconciliation_plan) diff --git a/account_reconcile_restrict_partner_mismatch/readme/CREDITS.md b/account_reconcile_restrict_partner_mismatch/readme/CREDITS.md index 4351fe296..5dfda7ecb 100644 --- a/account_reconcile_restrict_partner_mismatch/readme/CREDITS.md +++ b/account_reconcile_restrict_partner_mismatch/readme/CREDITS.md @@ -1,2 +1,3 @@ The migration of this module from 13.0 to 14.0 was financially supported +The migration of this module from 16.0 to 18.0 was financially supported by Camptocamp diff --git a/account_reconcile_restrict_partner_mismatch/report/account_move_lines_report.xml b/account_reconcile_restrict_partner_mismatch/report/account_move_lines_report.xml index c5930500e..fa294e360 100644 --- a/account_reconcile_restrict_partner_mismatch/report/account_move_lines_report.xml +++ b/account_reconcile_restrict_partner_mismatch/report/account_move_lines_report.xml @@ -4,7 +4,7 @@ Reconciled items with partner mismatch account.reconcile.partner.mismatch.report - + @@ -17,7 +17,7 @@ - + @@ -57,7 +57,7 @@ > Reconciled items with partner mismatch account.reconcile.partner.mismatch.report - tree,form + list,form Contributors

Other credits

The migration of this module from 13.0 to 14.0 was financially supported +The migration of this module from 16.0 to 18.0 was financially supported by Camptocamp

diff --git a/account_reconcile_restrict_partner_mismatch/tests/test_reconciliation.py b/account_reconcile_restrict_partner_mismatch/tests/test_reconciliation.py index 1be0bd1d8..7d8b78132 100644 --- a/account_reconcile_restrict_partner_mismatch/tests/test_reconciliation.py +++ b/account_reconcile_restrict_partner_mismatch/tests/test_reconciliation.py @@ -2,10 +2,12 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from odoo.exceptions import UserError +from odoo.tests import tagged from odoo.addons.base.tests.common import BaseCommon +@tagged("-at_install", "post_install") class TestReconciliation(BaseCommon): @classmethod def setUpClass(cls): @@ -141,3 +143,28 @@ def test_reconcile_accounts_excluded(self): self.aml.move_id.action_post() self.aml.reconcile() self.assertTrue(all(self.aml.mapped("reconciled"))) + + def test_reconcile_same_partner(self): + """Test reconciliation of two move lines with same partner works.""" + self.aml.move_id.company_id.restrict_partner_mismatch_on_reconcile = True + # Set same partner for both lines + self.aml.write({'partner_id': self.partner.id}) + self.aml.move_id.action_post() + self.aml.reconcile() + self.assertTrue(all(self.aml.mapped("reconciled"))) + + def test_reconcile_different_journals(self): + """Test reconciliation works across different journals.""" + # Create second journal + cash_journal = self.env["account.journal"].create( + {"name": "Cash", "type": "cash", "code": "CSH67"} + ) + + # Update journals of existing moves + self.aml[0].move_id.journal_id = self.bank_journal + self.aml[1].move_id.journal_id = cash_journal + + # Test reconciliation + self.aml.move_id.action_post() + self.aml.reconcile() + self.assertTrue(all(self.aml.mapped("reconciled"))) diff --git a/account_reconcile_restrict_partner_mismatch/views/account_journal.xml b/account_reconcile_restrict_partner_mismatch/views/account_journal.xml index d1b3a4f14..07580a658 100644 --- a/account_reconcile_restrict_partner_mismatch/views/account_journal.xml +++ b/account_reconcile_restrict_partner_mismatch/views/account_journal.xml @@ -7,7 +7,7 @@ res.config.settings -
-

Partners Mismatch Restriction on Reconcile

-
-
-
-
- -
-
-
-
-
-
-
+ + + + + + +