From 8c4e855a1b85b83a948c36dbe8bbcd8e68c34372 Mon Sep 17 00:00:00 2001 From: Ricardo Gomes Rodrigues Date: Tue, 17 Oct 2023 13:16:46 +0200 Subject: [PATCH] [FIX] account_reports: warn user if some accounts are deprecated while generating the grouped deferral entries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, if a user has an active deferred entry whose account has been deprecated in the mean time, we create a move line containing this deprecated account which raises an unclear error to the user. Now, instead, we let the user create deferral entries for deprecated accounts. We also add a test to check that old moves are not taken into account when generating deferral entries. task-id 3544877 closes odoo/odoo#140155 X-original-commit: 47f97fb208ee6c6fc4ce522bc7ad648ea6bbe07c Related: odoo/enterprise#49758 Signed-off-by: William André (wan) Signed-off-by: Ricardo Gomes Rodrigues (rigr) --- addons/account/models/account_move.py | 2 +- addons/account/models/account_move_line.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 527e80e3d6d..4f57d6c1d1e 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -3713,7 +3713,7 @@ class AccountMove(models.Model): move.currency_id.name )) - if move.line_ids.account_id.filtered(lambda account: account.deprecated): + if move.line_ids.account_id.filtered(lambda account: account.deprecated) and not self._context.get('skip_account_deprecation_check'): raise UserError(_("A line of this move is using a deprecated account, you cannot post it.")) if soft: diff --git a/addons/account/models/account_move_line.py b/addons/account/models/account_move_line.py index fa02a11ef34..11ea9f7fdc8 100644 --- a/addons/account/models/account_move_line.py +++ b/addons/account/models/account_move_line.py @@ -1225,7 +1225,7 @@ class AccountMoveLine(models.Model): account = line.account_id journal = line.move_id.journal_id - if account.deprecated: + if account.deprecated and not self.env.context.get('skip_account_deprecation_check'): raise UserError(_('The account %s (%s) is deprecated.', account.name, account.code)) account_currency = account.currency_id