[FIX] account_reports: warn user if some accounts are deprecated while generating the grouped deferral entries

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) <wan@odoo.com>
Signed-off-by: Ricardo Gomes Rodrigues (rigr) <rigr@odoo.com>
This commit is contained in:
Ricardo Gomes Rodrigues
2023-10-30 16:41:45 +00:00
parent f54c572152
commit 8c4e855a1b
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -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:
+1 -1
View File
@@ -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