From cb0ff3bc649bfaa9d43807a23b2e742a6fa56b95 Mon Sep 17 00:00:00 2001 From: gawa-odoo Date: Wed, 26 Oct 2022 15:45:21 +0000 Subject: [PATCH] [FIX] project_purchase: analytic_distribution and recordset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In `_compute_analytic_distribution`, we're dealing with recordset and so, should iterate on it. Also, the distribution expects an id, not the record. closes odoo/odoo#104458 X-original-commit: d41d5ef7aebc9f65066ecf86939e3f60aa515539 Related: odoo/enterprise#33378 Signed-off-by: William André (wan) Signed-off-by: Wala Gauthier (gawa) --- addons/project_purchase/models/purchase_order_line.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/project_purchase/models/purchase_order_line.py b/addons/project_purchase/models/purchase_order_line.py index 85efce71aa2..deff88f3688 100644 --- a/addons/project_purchase/models/purchase_order_line.py +++ b/addons/project_purchase/models/purchase_order_line.py @@ -9,5 +9,6 @@ class PurchaseOrderLine(models.Model): def _compute_analytic_distribution(self): super()._compute_analytic_distribution() - if self._context.get('project_id'): - self.analytic_distribution = {self.env['project.project'].browse(self._context['project_id']).analytic_account_id: 100} + for line in self: + if line._context.get('project_id'): + line.analytic_distribution = {line.env['project.project'].browse(line._context['project_id']).analytic_account_id.id: 100}