diff --git a/addons/website_sale_product_configurator/controllers/main.py b/addons/website_sale_product_configurator/controllers/main.py index 055a06d17bc..343ec003402 100644 --- a/addons/website_sale_product_configurator/controllers/main.py +++ b/addons/website_sale_product_configurator/controllers/main.py @@ -22,7 +22,7 @@ class WebsiteSaleProductConfiguratorController(Controller): already_configured = bool(combination) if not force_dialog and not has_optional_products and ( - not product.has_configurable_attributes or already_configured + product.product_variant_count <= 1 or already_configured ): # The modal is not shown if there are no optional products and # the main product either has no variants or is already configured diff --git a/addons/website_sale_product_configurator/static/tests/tours/website_sale_configurator_only_dynamic_attributes.js b/addons/website_sale_product_configurator/static/tests/tours/website_sale_configurator_only_dynamic_attributes.js deleted file mode 100644 index a918893f14e..00000000000 --- a/addons/website_sale_product_configurator/static/tests/tours/website_sale_configurator_only_dynamic_attributes.js +++ /dev/null @@ -1,29 +0,0 @@ -/** @odoo-module **/ - -import { registry } from "@web/core/registry"; -import tourUtils from "@website_sale/js/tours/tour_utils"; - -registry.category("web_tour.tours").add('tour_configurator_quick_add_only_no_dynamic_attributes', { - test: true, - url: '/shop', - steps: () => [ - ...tourUtils.searchProduct("Short (TEST)"), - { - content: "open configurator", - trigger: '.oe_product:has(a:contains("Short (TEST)")) div.o_wsale_product_btn a', - }, - { - content: "select M dynamic attribute", - trigger: '.oe_advanced_configurator_modal label:contains("M dynamic") input', - }, - { - content: "Go through the modal window of the product configurator", - extra_trigger: '.oe_advanced_configurator_modal strong:contains("Short (TEST) (M dynamic)")', - trigger: 'button span:contains(Proceed to Checkout)', - }, - tourUtils.assertCartContains({ - productName: 'Short (TEST) (M dynamic)', - backend: false, - }), - ] -}); diff --git a/addons/website_sale_product_configurator/static/tests/tours/website_sale_configurator_only_no_variant_attributes.js b/addons/website_sale_product_configurator/static/tests/tours/website_sale_configurator_only_no_variant_attributes.js deleted file mode 100644 index 434fcf0823f..00000000000 --- a/addons/website_sale_product_configurator/static/tests/tours/website_sale_configurator_only_no_variant_attributes.js +++ /dev/null @@ -1,29 +0,0 @@ -/** @odoo-module **/ - -import { registry } from "@web/core/registry"; -import tourUtils from "@website_sale/js/tours/tour_utils"; - -registry.category("web_tour.tours").add('tour_configurator_quick_add_only_no_variant_attributes', { - test: true, - url: '/shop', - steps: () => [ - ...tourUtils.searchProduct("Short (TEST)"), - { - content: "open configurator", - trigger: '.oe_product:has(a:contains("Short (TEST)")) div.o_wsale_product_btn a', - }, - { - content: "select M dynamic attribute", - trigger: '.oe_advanced_configurator_modal label:contains("M never") input', - }, - { - content: "Go through the modal window of the product configurator", - trigger: 'button span:contains(Continue Shopping)', - }, - { - content: "check that the novariants/custom attributes are displayed.", - trigger: '.toast-body span.text-muted.small:contains("Never attribute size: M never")', - isCheck: true, - }, - ] -}); diff --git a/addons/website_sale_product_configurator/static/tests/tours/website_sale_configurator_single_custom_attribute.js b/addons/website_sale_product_configurator/static/tests/tours/website_sale_configurator_single_custom_attribute.js deleted file mode 100644 index 31e4736fa21..00000000000 --- a/addons/website_sale_product_configurator/static/tests/tours/website_sale_configurator_single_custom_attribute.js +++ /dev/null @@ -1,29 +0,0 @@ -/** @odoo-module **/ - -import { registry } from "@web/core/registry"; -import tourUtils from "@website_sale/js/tours/tour_utils"; - -registry.category("web_tour.tours").add('tour_configurator_quick_add_single_custom_attribute', { - test: true, - url: '/shop', - steps: () => [ - ...tourUtils.searchProduct("Short (TEST)"), - { - content: "open configurator", - trigger: '.oe_product:has(a:contains("Short (TEST)")) div.o_wsale_product_btn a', - }, - { - trigger: 'input.variant_custom_value', - run: 'text TEST', - }, - { - content: "Go through the modal window of the product configurator", - trigger: 'button span:contains(Continue Shopping)', - }, - { - content: "check that the novariants/custom attributes are displayed.", - trigger: '.toast-body span.text-muted.small:contains("Always attribute size: Yes never custom: TEST")', - isCheck: true, - }, - ] -}); diff --git a/addons/website_sale_product_configurator/tests/test_website_sale_configurator.py b/addons/website_sale_product_configurator/tests/test_website_sale_configurator.py index faa2cec73ee..06a12deace0 100644 --- a/addons/website_sale_product_configurator/tests/test_website_sale_configurator.py +++ b/addons/website_sale_product_configurator/tests/test_website_sale_configurator.py @@ -1,6 +1,5 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo.fields import Command from odoo.tests import tagged from odoo.addons.base.tests.common import HttpCaseWithUserDemo, HttpCaseWithUserPortal @@ -147,86 +146,3 @@ class TestWebsiteSaleProductConfigurator(TestProductConfiguratorCommon, HttpCase new_sale_order = self.env['sale.order'].search([]) - old_sale_order new_order_line = new_sale_order.order_line self.assertEqual(new_order_line.name, 'Short (TEST) (M always, M dynamic)\n\nNever attribute size: M never\nNever attribute size custom: Yes never custom: TEST') - - def test_03_only_no_variant_attributes(self): - """ Test that the configurator dialog is opened when a product with only no variant - attributes is added from the /shop page. - """ - self.env.ref('website_sale.products_add_to_cart').active = True # Enable quick add button - no_variant_attribute = self.env['product.attribute'].create({ - 'name': 'Never attribute size', - 'display_type': 'radio', - 'create_variant': 'no_variant', - 'value_ids': [ - Command.create({'name': 'S never'}), - Command.create({'name': 'M never'}), - ] - }) - self.env['product.template'].create({ - 'name': 'Short (TEST)', - 'website_published': True, - 'attribute_line_ids': [ - Command.create({ - 'attribute_id': no_variant_attribute.id, - 'value_ids': [Command.set(no_variant_attribute.value_ids.ids)], - }) - ], - }) - - self.start_tour("/shop", 'tour_configurator_quick_add_only_no_variant_attributes') - - def test_04_only_dynamic_attributes(self): - """ Test that the configurator dialog is opened when a product with only dynamic - attributes is added from the /shop page. - """ - self.env.ref('website_sale.products_add_to_cart').active = True # Enable quick add button - dynamic_attribute = self.env['product.attribute'].create({ - 'name': 'Dynamic attribute size', - 'display_type': 'radio', - 'create_variant': 'dynamic', - 'value_ids': [ - Command.create({'name': 'S dynamic'}), - Command.create({'name': 'M dynamic'}), - ] - }) - self.env['product.template'].create({ - 'name': 'Short (TEST)', - 'website_published': True, - 'attribute_line_ids': [ - Command.create({ - 'attribute_id': dynamic_attribute.id, - 'value_ids': [Command.set(dynamic_attribute.value_ids.ids)], - }) - ], - }) - - self.start_tour("/shop", 'tour_configurator_quick_add_only_no_dynamic_attributes') - - def test_05_single_custom_attribute(self): - """ Test that the configurator dialog is opened when a product with a single custom - attributes is added from the /shop page. - """ - self.env.ref('website_sale.products_add_to_cart').active = True # Enable quick add button - attribute = self.env['product.attribute'].create({ - 'name': 'Always attribute size', - 'display_type': 'radio', - 'create_variant': 'always', - 'value_ids': [ - Command.create({ - 'name': 'Yes never custom', - 'is_custom': True, - }), - ] - }) - self.env['product.template'].create({ - 'name': 'Short (TEST)', - 'website_published': True, - 'attribute_line_ids': [ - Command.create({ - 'attribute_id': attribute.id, - 'value_ids': [Command.set(attribute.value_ids.ids)], - }) - ], - }) - - self.start_tour("/shop", 'tour_configurator_quick_add_single_custom_attribute') diff --git a/addons/website_sale_product_configurator/views/templates.xml b/addons/website_sale_product_configurator/views/templates.xml index 3fe01e55e5f..775ed93bcf7 100644 --- a/addons/website_sale_product_configurator/views/templates.xml +++ b/addons/website_sale_product_configurator/views/templates.xml @@ -77,7 +77,7 @@ - +