From 0f04e6052a504f95dc8163f56583341c0aa4a55f Mon Sep 17 00:00:00 2001 From: Juan Jose Scarafia Date: Wed, 17 May 2023 17:03:10 -0300 Subject: [PATCH] [FIX] account: multicompany depends --- addons/account/models/account_move.py | 5 +++-- addons/account/models/account_move_line.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 91aec7e4b2d6e..49e2639c986db 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -770,16 +770,17 @@ def _compute_fiscal_position_id(self): move.fiscal_position_id = self.env['account.fiscal.position'].with_company(move.company_id)._get_fiscal_position( move.partner_id, delivery=delivery_partner) - @api.depends('bank_partner_id') + @api.depends('bank_partner_id', 'company_id') def _compute_partner_bank_id(self): for move in self: bank_ids = move.bank_partner_id.bank_ids.filtered( lambda bank: not bank.company_id or bank.company_id == move.company_id) move.partner_bank_id = bank_ids[0] if bank_ids else False - @api.depends('partner_id') + @api.depends('partner_id', 'company_id') def _compute_invoice_payment_term_id(self): for move in self: + move = move.with_company(move.company_id) if move.is_sale_document(include_receipts=True) and move.partner_id.property_payment_term_id: move.invoice_payment_term_id = move.partner_id.property_payment_term_id elif move.is_purchase_document(include_receipts=True) and move.partner_id.property_supplier_payment_term_id: diff --git a/addons/account/models/account_move_line.py b/addons/account/models/account_move_line.py index 007bda25bea0e..cab0fcb213042 100644 --- a/addons/account/models/account_move_line.py +++ b/addons/account/models/account_move_line.py @@ -499,6 +499,7 @@ def _compute_account_id(self): WHERE line.move_id = ANY(%(move_ids)s) AND line.display_type = 'payment_term' AND line.id != ANY(%(current_ids)s) + AND company_id = ANY(%(company_ids)s) ), properties AS( SELECT DISTINCT ON (property.company_id, property.name) @@ -858,7 +859,7 @@ def _compute_price_unit(self): product_uom=line.product_uom_id, ) - @api.depends('product_id', 'product_uom_id') + @api.depends('product_id', 'product_uom_id', 'company_id') def _compute_tax_ids(self): for line in self: if line.display_type in ('line_section', 'line_note'):