From 34d4ffa01d57de8a1795ce0710d3585a2054a587 Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Mon, 30 Jan 2023 13:55:51 +0000 Subject: [PATCH] [FIX] website_sale: fix re-order feature on SO portal page SO portal page may have `[Order Again]` button. It's visible when there is at least one line with a product that might be reordered ("Added to cart"). This check fails with error "Expected singleton: product.product()" if first line is a section name or a note. Fix it by excluding such lines from `any(...)` check. STEPS: * Activate "Re-order From Portal" * Create and confirm order that has section (or a note) as a first line * Click `Customer Preview` smart button Call stack: https://github.com/odoo/odoo/blob/c4b90db77705139333bdf5faf26b12fc120d1661/addons/website_sale/views/templates.xml#L2466-L2471 https://github.com/odoo/odoo/blob/c4b90db77705139333bdf5faf26b12fc120d1661/addons/website_sale/models/sale_order.py#L420-L422 https://github.com/odoo/odoo/blob/c4b90db77705139333bdf5faf26b12fc120d1661/addons/website_sale/models/sale_order_line.py#L62-L64 https://github.com/odoo/odoo/blob/c4b90db77705139333bdf5faf26b12fc120d1661/addons/website_sale/models/product_product.py#L95-L97 Original commit that introduces re-order feature: https://github.com/odoo/odoo/commit/fef332bec4447b7ce8d789af8773c56688f4958a opw-3141929 closes odoo/odoo#112788 X-original-commit: 7fa388e3394af624b3dd69fbf9a8b8b992d655fb Signed-off-by: William Braeckman (wbr) --- addons/website_sale/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website_sale/models/sale_order.py b/addons/website_sale/models/sale_order.py index b70e34e747b..a19dc92c62b 100644 --- a/addons/website_sale/models/sale_order.py +++ b/addons/website_sale/models/sale_order.py @@ -434,7 +434,7 @@ class SaleOrder(models.Model): def _is_reorder_allowed(self): self.ensure_one() - return self.state == 'sale' and any(line._is_reorder_allowed() for line in self.order_line) + return self.state == 'sale' and any(line._is_reorder_allowed() for line in self.order_line if not line.display_type) def _filter_can_send_abandoned_cart_mail(self): self.website_id.ensure_one()