From da76c7c47b768d13c1d613d14e7c3bf74d283607 Mon Sep 17 00:00:00 2001 From: Nans Lefebvre Date: Mon, 14 Oct 2019 12:09:25 +0000 Subject: [PATCH] [FIX] website_sale, website_sale_product_configurator: fix cart update Commits df2ea31ff6e and 55ed70f405a moved things around, "without any functional change". They made it so that if you add twice a product to the cart, they are added in different lines instead of merged. There are two issues: - the `if line_id: return lines` made sense when the post-filtering was in the same function, since it could readily be avoided - conversely the post-filtering was avoided in the function that was added with the only goal to do it, except in the case where it was useless (the case where lines is an empty recordset). opw 2083729 closes odoo/odoo#38938 X-original-commit: c9c0a0c322f02974bc6395410ca3d7213899c7e0 Signed-off-by: Nans Lefebvre (len) --- addons/website_sale/models/sale_order.py | 7 +------ .../website_sale_product_configurator/models/sale_order.py | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/addons/website_sale/models/sale_order.py b/addons/website_sale/models/sale_order.py index 9ae5755a2f5..3cb129b2abc 100644 --- a/addons/website_sale/models/sale_order.py +++ b/addons/website_sale/models/sale_order.py @@ -89,12 +89,7 @@ class SaleOrder(models.Model): else: domain += [('product_custom_attribute_value_ids', '=', False)] - lines = self.env['sale.order.line'].sudo().search(domain) - - if line_id: - return lines - - return self.env['sale.order.line'] + return self.env['sale.order.line'].sudo().search(domain) def _website_product_id_change(self, order_id, product_id, qty=0): order = self.sudo().browse(order_id) diff --git a/addons/website_sale_product_configurator/models/sale_order.py b/addons/website_sale_product_configurator/models/sale_order.py index 943fd23f22a..3d25c8f9769 100644 --- a/addons/website_sale_product_configurator/models/sale_order.py +++ b/addons/website_sale_product_configurator/models/sale_order.py @@ -9,7 +9,7 @@ class SaleOrder(models.Model): def _cart_find_product_line(self, product_id=None, line_id=None, **kwargs): lines = super(SaleOrder, self)._cart_find_product_line(product_id, line_id, **kwargs) - if lines: + if line_id: # in this case we get the exact line we want, so filtering below would be wrong return lines linked_line_id = kwargs.get('linked_line_id', False)