From 0462ab901fd6f1024f8ad823465979680124c09d Mon Sep 17 00:00:00 2001 From: roen-odoo Date: Wed, 21 Feb 2024 14:52:40 +0100 Subject: [PATCH] [FIX] point_of_sale: add product attribute with multi selection Current behavior: When adding a product with a multi selection attribute, the attribute is not displayed in the product configurator popup. This only happens when opening it on a mobile device. Steps to reproduce: - Add a product with a multi selection attribute - Open PoS - Add the product to the order - The attribute is not shown on the product configurator popup opw-3711164 closes odoo/odoo#154893 Signed-off-by: Joseph Caburnay (jcb) --- .../product_configurator_popup.xml | 1 + .../static/tests/tours/ProductScreen.tour.js | 15 ++++++++++ .../helpers/ProductConfiguratorTourMethods.js | 10 +++++++ addons/point_of_sale/tests/test_frontend.py | 30 +++++++++++++++++++ 4 files changed, 56 insertions(+) diff --git a/addons/point_of_sale/static/src/app/store/product_configurator_popup/product_configurator_popup.xml b/addons/point_of_sale/static/src/app/store/product_configurator_popup/product_configurator_popup.xml index 1db839957a3..637d12f4775 100644 --- a/addons/point_of_sale/static/src/app/store/product_configurator_popup/product_configurator_popup.xml +++ b/addons/point_of_sale/static/src/app/store/product_configurator_popup/product_configurator_popup.xml @@ -165,6 +165,7 @@ + diff --git a/addons/point_of_sale/static/tests/tours/ProductScreen.tour.js b/addons/point_of_sale/static/tests/tours/ProductScreen.tour.js index 3963d502f67..60f5ab8fc4c 100644 --- a/addons/point_of_sale/static/tests/tours/ProductScreen.tour.js +++ b/addons/point_of_sale/static/tests/tours/ProductScreen.tour.js @@ -7,6 +7,7 @@ import * as ReceiptScreen from "@point_of_sale/../tests/tours/helpers/ReceiptScr import { registry } from "@web/core/registry"; import * as Order from "@point_of_sale/../tests/tours/helpers/generic_components/OrderWidgetMethods"; import { inLeftSide, scan_barcode } from "@point_of_sale/../tests/tours/helpers/utils"; +import * as ProductConfiguratorPopup from "@point_of_sale/../tests/tours/helpers/ProductConfiguratorTourMethods"; registry.category("web_tour.tours").add("ProductScreenTour", { test: true, @@ -202,3 +203,17 @@ registry.category("web_tour.tours").add("limitedProductPricelistLoading", { Chrome.endTour(), ].flat(), }); + +registry.category("web_tour.tours").add("MultiProductOptionsTour", { + test: true, + steps: () => + [ + ProductScreen.confirmOpeningPopup(), + + ProductScreen.clickDisplayedProduct("Product A"), + ProductConfiguratorPopup.isOptionShown("Value 1"), + ProductConfiguratorPopup.isOptionShown("Value 2"), + + Chrome.endTour(), + ].flat(), +}); diff --git a/addons/point_of_sale/static/tests/tours/helpers/ProductConfiguratorTourMethods.js b/addons/point_of_sale/static/tests/tours/helpers/ProductConfiguratorTourMethods.js index 30dea9d7d8e..d60c80dafbd 100644 --- a/addons/point_of_sale/static/tests/tours/helpers/ProductConfiguratorTourMethods.js +++ b/addons/point_of_sale/static/tests/tours/helpers/ProductConfiguratorTourMethods.js @@ -60,3 +60,13 @@ export function isShown() { }, ]; } + +export function isOptionShown(option) { + return [ + { + content: `option ${option} is shown`, + trigger: `.form-check-label:contains('${option}')`, + run: () => {}, + }, + ]; +} diff --git a/addons/point_of_sale/tests/test_frontend.py b/addons/point_of_sale/tests/test_frontend.py index d1afed74432..08ba2db7a96 100644 --- a/addons/point_of_sale/tests/test_frontend.py +++ b/addons/point_of_sale/tests/test_frontend.py @@ -1108,6 +1108,36 @@ class TestUi(TestPointOfSaleHttpCommon): self.main_pos_config.open_ui() self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'limitedProductPricelistLoading', login="accountman") + def test_multi_product_options(self): + product_a = self.env['product.product'].create({ + 'name': 'Product A', + 'available_in_pos': True, + 'list_price': 10, + 'taxes_id': False, + }) + + chair_multi_attribute = self.env['product.attribute'].create({ + 'name': 'Multi', + 'display_type': 'multi', + 'create_variant': 'no_variant', + }) + chair_multi_value_1 = self.env['product.attribute.value'].create({ + 'name': 'Value 1', + 'attribute_id': chair_multi_attribute.id, + }) + chair_multi_value_2 = self.env['product.attribute.value'].create({ + 'name': 'Value 2', + 'attribute_id': chair_multi_attribute.id, + }) + self.chair_multi_line = self.env['product.template.attribute.line'].create({ + 'product_tmpl_id': product_a.product_tmpl_id.id, + 'attribute_id': chair_multi_attribute.id, + 'value_ids': [(6, 0, [chair_multi_value_1.id, chair_multi_value_2.id])] + }) + + self.main_pos_config.with_user(self.pos_user).open_ui() + self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'MultiProductOptionsTour', login="pos_user") + # This class just runs the same tests as above but with mobile emulation class MobileTestUi(TestUi): browser_size = '375x667'