From 5d42dfcf338979fc753026d824dd27f9415b9eaf Mon Sep 17 00:00:00 2001 From: Louis Baudoux Date: Mon, 6 Sep 2021 10:22:08 +0000 Subject: [PATCH] [FIX] account: fix `bank_id` from another company When using module `account_invoice_extract`, it would happen that a bank account of another company was set on the `account.move`. This happened when the extract update was done in background via the cron. A check on the company of the bank account fixes the issue. opw-2631833 closes odoo/odoo#76024 X-original-commit: 12559929a551c7f837facb8242333e9b0285950b Signed-off-by: Laurent Smet Signed-off-by: Louis Baudoux --- addons/account/models/account_move.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 3d65c87a7e7..b6417725de4 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -495,7 +495,8 @@ class AccountMove(models.Model): line.account_id = new_term_account self._compute_bank_partner_id() - self.partner_bank_id = self.bank_partner_id.bank_ids and self.bank_partner_id.bank_ids[0] + bank_ids = self.bank_partner_id.bank_ids.filtered(lambda bank: bank.company_id is False or bank.company_id == self.company_id) + self.partner_bank_id = bank_ids and bank_ids[0] # Find the new fiscal position. delivery_partner_id = self._get_invoice_delivery_partner_id()