From 87f1106e5aefde0b348dd3cd5acc27ea3b403208 Mon Sep 17 00:00:00 2001 From: "Bastien (bvdn)" Date: Thu, 11 Apr 2024 17:16:30 +0200 Subject: [PATCH] [FIX] product, purchase, sale: fix default productType traceback The linked PR: https://github.com/odoo/odoo/pull/155157/files Added a default props 'productType' for ProductCatalogOrderLines, the value of this prop wasn't loaded by the backend correctly resulting in a traceback when in debug mode and trying to open the catalog from sale/fsm and another traceback when trying to open the catalog from the purchase form This PR loads the type of the product into the dictionnary corretly closes odoo/odoo#161541 Signed-off-by: Xavier Bol (xbo) --- addons/product/models/product_catalog_mixin.py | 2 +- addons/purchase/models/purchase_order.py | 2 +- addons/sale/models/sale_order.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/product/models/product_catalog_mixin.py b/addons/product/models/product_catalog_mixin.py index f8bc7b97d8f..7735fa12f0c 100644 --- a/addons/product/models/product_catalog_mixin.py +++ b/addons/product/models/product_catalog_mixin.py @@ -96,7 +96,7 @@ class ProductCatalogMixin(models.AbstractModel): for product, record_lines in self._get_product_catalog_record_lines(product_ids).items(): order_line_info[product.id] = { - **record_lines._get_product_catalog_lines_data(parent_record=self, **kwargs), + **record_lines._get_product_catalog_lines_data(**kwargs), 'productType': product.type, } product_ids.remove(product.id) diff --git a/addons/purchase/models/purchase_order.py b/addons/purchase/models/purchase_order.py index 585fe772d41..4e81661553a 100644 --- a/addons/purchase/models/purchase_order.py +++ b/addons/purchase/models/purchase_order.py @@ -846,7 +846,7 @@ class PurchaseOrder(models.Model): def _get_product_catalog_order_data(self, products, **kwargs): res = super()._get_product_catalog_order_data(products, **kwargs) for product in products: - res[product.id] += self._get_product_price_and_data(product) + res[product.id] |= self._get_product_price_and_data(product) return res def _get_product_catalog_record_lines(self, product_ids): diff --git a/addons/sale/models/sale_order.py b/addons/sale/models/sale_order.py index 9401f5e91f3..73a27662d52 100644 --- a/addons/sale/models/sale_order.py +++ b/addons/sale/models/sale_order.py @@ -1824,7 +1824,7 @@ class SaleOrder(models.Model): ) res = super()._get_product_catalog_order_data(products, **kwargs) for product in products: - res[product.id] = {'price': pricelist.get(product.id)} + res[product.id]['price'] = pricelist.get(product.id) if product.sale_line_warn != 'no-message' and product.sale_line_warn_msg: res[product.id]['warning'] = product.sale_line_warn_msg if product.sale_line_warn == "block":