From 4036381b682d2e6bed1fc9196a588eef2ee15d47 Mon Sep 17 00:00:00 2001 From: Bruno-brsy Date: Mon, 13 Dec 2021 09:48:18 +0000 Subject: [PATCH] [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 Signed-off-by: Bruno-brsy --- addons/account/i18n/account.pot | 8 ++++++++ addons/account/models/account_move.py | 2 ++ 2 files changed, 10 insertions(+) diff --git a/addons/account/i18n/account.pot b/addons/account/i18n/account.pot index e9d88412c7f..4e3608fad07 100644 --- a/addons/account/i18n/account.pot +++ b/addons/account/i18n/account.pot @@ -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 diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 4f8362663d1..ff561ad737d 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -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):