[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:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user