From 4a415aba2eb2df2fa5f60fe53bdb9db3f92141e8 Mon Sep 17 00:00:00 2001 From: tsb-odoo Date: Tue, 19 Jul 2022 21:41:43 +0000 Subject: [PATCH] [FIX] account: analytic account fix in multicompanies env When using _prepare_analytic_distribution_line, it would take the company for the line from the distribution, then the env. This would cause multicompany issues in some case, creating the line for the wrong company. By using current the move line to get the company before falling back on the env, we can avoid such an issue. OPW-2900827 closes odoo/odoo#96465 X-original-commit: 8c10324f062e4cd239494545cdfce7cde7ffadbb Signed-off-by: Florian Gilbert (flg) --- addons/account/models/account_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index ca875fd1283..ade9543db25 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -5979,7 +5979,7 @@ class AccountMoveLine(models.Model): 'ref': self.ref, 'move_id': self.id, 'user_id': self.move_id.invoice_user_id.id or self._uid, - 'company_id': distribution.account_id.company_id.id or self.env.company.id, + 'company_id': distribution.account_id.company_id.id or self.company_id.id or self.env.company.id, } @api.model