[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) <flg@odoo.com>
This commit is contained in:
tsb-odoo
2022-07-27 03:34:57 +02:00
committed by Nicolas (vin)
parent 901a43f532
commit 4a415aba2e
+1 -1
View File
@@ -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