From fe1d946887e3197696b3efe03663e24ff1ef4b8b Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 27 Mar 2020 10:22:51 +0000 Subject: [PATCH] [FIX] account: check entry at posting External addons (such as the POS) can create entries and end up bypassing the `_check_balanced` in the whole process. We force a check at posting, since at this point there is no reason to have an unbalanced entry anymore. opw-2168096 closes odoo/odoo#49489 X-original-commit: 88902e2d3953a311dfb3629daeebf22b8874b6e9 Signed-off-by: Nicolas Martinelli (nim) --- addons/account/models/account_move.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index c73f240da4a..9531a72baee 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -2307,6 +2307,10 @@ class AccountMove(models.Model): lambda m: m.is_invoice(include_receipts=True) and m.currency_id.is_zero(m.amount_total) ).action_invoice_paid() + # Force balance check since nothing prevents another module to create an incorrect entry. + # This is performed at the very end to avoid flushing fields before the whole processing. + self._check_balanced() + def _auto_compute_invoice_reference(self): ''' Hook to be overridden to set custom conditions for auto-computed invoice references. :return True if the move should get a auto-computed reference else False