From be7bcdaf7e995bbadb8bc1ffb48fc8f154807183 Mon Sep 17 00:00:00 2001 From: Maitri Patel Date: Mon, 5 Jun 2023 12:51:49 +0000 Subject: [PATCH] [FIX] purchase: prevent traceback when creating PO without company_id when the user removes the company_id and add a line in the purchase order then the issue is generated. Steps to reproduce: - Create a new purchase order. - Remove the company_id in the Purchase order. - Now add a line in PO. Select a product with the consumable product type. - Traceback will be generated. Applying these changes will resolve this issue. Sentry-4215579151 closes odoo/odoo#124035 X-original-commit: 75edec6f73b70c4b9b86ad67bc838f468c2574b7 Signed-off-by: Tiffany Chang --- addons/purchase/models/purchase.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index 34ba86005dd..49924ebd1f6 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -1227,10 +1227,10 @@ class PurchaseOrderLine(models.Model): return {'warning': warning} return {} - @api.depends('product_qty', 'product_uom') + @api.depends('product_qty', 'product_uom', 'company_id') def _compute_price_unit_and_date_planned_and_name(self): for line in self: - if not line.product_id or line.invoice_lines: + if not line.product_id or line.invoice_lines or not line.company_id: continue params = {'order_id': line.order_id} seller = line.product_id._select_seller(