From f51f2d56749b394c8c957a15362acdcf31ea485d Mon Sep 17 00:00:00 2001 From: "Mahdi Cheikh Rouhou (macr)" Date: Wed, 15 Nov 2023 08:44:36 +0000 Subject: [PATCH] [FIX] pos_self_order: compute price product variants in self order Issue: ====== When choosing product with attributes that have attributes which have variant creation mode never it will not take into account the extra price. Steps to reproduce the issue: ============================= - Install pos , restaurant - Create a product which have `Size` attribute and add some values in it, 'S' and 'M' for example , then add extra prices in each one of them. Enable available in POS setting in Sales page of the product. - Got to point of sala , click on 3 dots in restaurant and open mobile menu. - Added the created product to cart and click review. - The price shown is the original price of the product and not taking into account the extra price of the attribute. Origin of the issue: ==================== This was not supported before Solution: ========= Using the attribute_value_ids value in the line we can calculate the extra_price of those attributes and add it to the price_unit so we can get taxed_amount and untaxed_amount correctly. opw-3511374 closes odoo/odoo#142485 X-original-commit: a54fddd9270b3431a8cde0a6bf30349c5671b0ac Signed-off-by: David Monnom (moda) Signed-off-by: Mahdi Cheikh Rouhou (macr) --- addons/pos_self_order/controllers/orders.py | 2 ++ .../static/tests/tours/test_self_order_attribute.js | 2 ++ addons/pos_self_order/tests/test_self_order_attribute.py | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/addons/pos_self_order/controllers/orders.py b/addons/pos_self_order/controllers/orders.py index 26d909669a6..ad4aa635a38 100644 --- a/addons/pos_self_order/controllers/orders.py +++ b/addons/pos_self_order/controllers/orders.py @@ -223,6 +223,8 @@ class PosSelfOrderController(http.Controller): line_qty = line.get('qty') product = pos_config.env['product.product'].browse(int(line.get('product_id'))) lst_price = pricelist._get_product_price(product, quantity=line_qty) if pricelist else product.lst_price + selected_attributes = fetched_attributes.browse(line.get('attribute_value_ids', [])) + lst_price += sum([attr.price_extra for attr in selected_attributes]) children = [l for l in lines if l.get('combo_parent_uuid') == line.get('uuid')] pos_combo_lines = combo_lines.browse([child.get('combo_line_id') for child in children]) diff --git a/addons/pos_self_order/static/tests/tours/test_self_order_attribute.js b/addons/pos_self_order/static/tests/tours/test_self_order_attribute.js index b2c310a993c..331c86a3f0e 100644 --- a/addons/pos_self_order/static/tests/tours/test_self_order_attribute.js +++ b/addons/pos_self_order/static/tests/tours/test_self_order_attribute.js @@ -19,6 +19,7 @@ registry.category("web_tour.tours").add("self_attribute_selector", { { name: "Size", value: "M" }, { name: "Fabric", value: "Leather" }, ]), + CartPage.checkProduct("Desk Organizer", "7.02", "1"), CartPage.clickBack(), ProductPage.clickProduct("Desk Organizer"), ...ProductPage.setupAttribute([ @@ -30,6 +31,7 @@ registry.category("web_tour.tours").add("self_attribute_selector", { { name: "Size", value: "L" }, { name: "Fabric", value: "Leather" }, ]), + CartPage.checkProduct("Desk Organizer", "8.17", "1"), Utils.clickBtn("Pay"), Utils.clickBtn("Ok"), Utils.clickBtn("My Order"), diff --git a/addons/pos_self_order/tests/test_self_order_attribute.py b/addons/pos_self_order/tests/test_self_order_attribute.py index 56ad50d0ce3..d0c045bf87e 100644 --- a/addons/pos_self_order/tests/test_self_order_attribute.py +++ b/addons/pos_self_order/tests/test_self_order_attribute.py @@ -16,6 +16,11 @@ class TestSelfOrderAttribute(SelfOrderCommonTest): 'self_ordering_service_mode': 'counter', }) + product = self.env['product.product'].search([('name', '=', 'Desk Organizer')])[0] + product.attribute_line_ids[0].product_template_value_ids[0].price_extra = 0.0 + product.attribute_line_ids[0].product_template_value_ids[1].price_extra = 1.0 + product.attribute_line_ids[0].product_template_value_ids[2].price_extra = 2.0 + self.pos_config.with_user(self.pos_user).open_ui() self_route = self.pos_config._get_self_order_route()