[FIX] account: Validate invoice with archived bank account

It's possible to confirm an invoice with an archived bank account of
the recipient. But it's not making any sense, since the bank account
is archived.

It's why we need to raise an error if the user want to confirm an
invoice with an archived bank account.

opw-2704605

closes odoo/odoo#81939

X-original-commit: 8b9ff034cb67b132cdb6736a5f18d70beb63c253
Signed-off-by: Laurent Smet <las@odoo.com>
Signed-off-by: Bruno-brsy <brsy@odoo.com>
This commit is contained in:
Bruno-brsy
2021-12-28 09:47:29 +00:00
parent 5b854f7f5f
commit 4036381b68
2 changed files with 10 additions and 0 deletions
+8
View File
@@ -13262,6 +13262,14 @@ msgstr ""
msgid "The payment's currency."
msgstr ""
#. module: account
#: code:addons/account/models/account_move.py:0
#, python-format
msgid ""
"The recipient bank account link to this invoice is archived.\n"
"So you cannot confirm the invoice."
msgstr ""
#. module: account
#: model:ir.model.fields,help:account.field_account_reconcile_model__match_partner_category_ids
#: model:ir.model.fields,help:account.field_account_reconcile_model_template__match_partner_category_ids
+2
View File
@@ -2934,6 +2934,8 @@ class AccountMove(models.Model):
if not self.env.su and not self.env.user.has_group('account.group_account_invoice'):
raise AccessError(_("You don't have the access rights to post an invoice."))
for move in to_post:
if move.partner_bank_id and not move.partner_bank_id.active:
raise UserError(_("The recipient bank account link to this invoice is archived.\nSo you cannot confirm the invoice."))
if move.state == 'posted':
raise UserError(_('The entry %s (id %s) is already posted.') % (move.name, move.id))
if not move.line_ids.filtered(lambda line: not line.display_type):