From 54ffd01b07f2136fe32e4679e87ac4612613158d Mon Sep 17 00:00:00 2001 From: "Thomas Lefebvre (thle)" Date: Tue, 21 Mar 2023 07:40:19 +0000 Subject: [PATCH] [FIX] website_sale, website_sale_product_configurator: move test Move the test because the field `optional_product_ids` is defined in the module "product_configurator". Therefore, if the test is in "website_sale" and is run without the "product_configurator" module there is an error. We move the test to the "bridge" module between "website_sale" and "product_configurator". opw-3140859 closes odoo/odoo#116742 X-original-commit: 4f4d6c1422b5b258fc5176a0f341b47c0fc1e963 Signed-off-by: Lefebvre Thomas (thle) --- addons/website_sale/tests/test_customize.py | 111 ------------------ .../website_sale_variants_modal_window.js | 0 .../tests/test_website_sale_configurator.py | 111 ++++++++++++++++++ 3 files changed, 111 insertions(+), 111 deletions(-) rename addons/{website_sale => website_sale_product_configurator}/static/tests/tours/website_sale_variants_modal_window.js (100%) diff --git a/addons/website_sale/tests/test_customize.py b/addons/website_sale/tests/test_customize.py index a754e45c1a1..fcd6a242ed6 100644 --- a/addons/website_sale/tests/test_customize.py +++ b/addons/website_sale/tests/test_customize.py @@ -402,114 +402,3 @@ class TestUi(HttpCaseWithUserDemo, HttpCaseWithUserPortal): product_template.product_variant_ids[-1].active = False self.start_tour("/", 'tour_shop_archived_variant_multi', login="portal") - - def test_09_variants_modal_window(self): - """ - The objective is to verify that the data concerning the variants are well transmitted - even when passing through a modal window (product configurator). - - We create a product with the different attributes and we will modify them. - If the information is not correctly transmitted, - the default values of the variants will be used (the first one). - """ - - always_attribute, dynamic_attribute, never_attribute, never_attribute_custom = self.env['product.attribute'].create([ - { - 'name': 'Always attribute size', - 'display_type': 'radio', - 'create_variant': 'always' - }, - { - 'name': 'Dynamic attribute size', - 'display_type': 'radio', - 'create_variant': 'dynamic' - }, - { - 'name': 'Never attribute size', - 'display_type': 'radio', - 'create_variant': 'no_variant' - }, - { - 'name': 'Never attribute size custom', - 'display_type': 'radio', - 'create_variant': 'no_variant' - } - ]) - always_S, always_M, dynamic_S, dynamic_M, never_S, never_M, never_custom_no, never_custom_yes = self.env['product.attribute.value'].create([ - { - 'name': 'S always', - 'attribute_id': always_attribute.id, - }, - { - 'name': 'M always', - 'attribute_id': always_attribute.id, - }, - { - 'name': 'S dynamic', - 'attribute_id': dynamic_attribute.id, - }, - { - 'name': 'M dynamic', - 'attribute_id': dynamic_attribute.id, - }, - { - 'name': 'S never', - 'attribute_id': never_attribute.id, - }, - { - 'name': 'M never', - 'attribute_id': never_attribute.id, - }, - { - 'name': 'No never custom', - 'attribute_id': never_attribute_custom.id, - }, - { - 'name': 'Yes never custom', - 'attribute_id': never_attribute_custom.id, - 'is_custom': True, - } - ]) - - product_short = self.env['product.template'].create({ - 'name': 'Short (TEST)', - 'website_published': True, - }) - - self.env['product.template.attribute.line'].create([ - { - 'product_tmpl_id': product_short.id, - 'attribute_id': always_attribute.id, - 'value_ids': [(4, always_S.id), (4, always_M.id)], - }, - { - 'product_tmpl_id': product_short.id, - 'attribute_id': dynamic_attribute.id, - 'value_ids': [(4, dynamic_S.id), (4, dynamic_M.id)], - }, - { - 'product_tmpl_id': product_short.id, - 'attribute_id': never_attribute.id, - 'value_ids': [(4, never_S.id), (4, never_M.id)], - }, - { - 'product_tmpl_id': product_short.id, - 'attribute_id': never_attribute_custom.id, - 'value_ids': [(4, never_custom_no.id), (4, never_custom_yes.id)], - }, - ]) - - # Add an optional product to trigger the modal window - optional_product = self.env['product.template'].create({ - 'name': 'Optional product (TEST)', - 'website_published': True, - }) - product_short.optional_product_ids = [(4, optional_product.id)] - - old_sale_order = self.env['sale.order'].search([]) - self.start_tour("/", 'tour_variants_modal_window', login="demo") - - # Check the name of the created sale order line - 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') diff --git a/addons/website_sale/static/tests/tours/website_sale_variants_modal_window.js b/addons/website_sale_product_configurator/static/tests/tours/website_sale_variants_modal_window.js similarity index 100% rename from addons/website_sale/static/tests/tours/website_sale_variants_modal_window.js rename to addons/website_sale_product_configurator/static/tests/tours/website_sale_variants_modal_window.js 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 1c9201dbfb6..e633c3cd9aa 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 @@ -35,3 +35,114 @@ class TestWebsiteSaleProductConfigurator(TestProductConfiguratorCommon, HttpCase # This ensures that tours with triggers on the amounts will run properly. self.env['product.pricelist'].search([]).action_archive() self.start_tour(url, 'website_sale_product_configurator_optional_products_tour', login='portal') + + def test_02_variants_modal_window(self): + """ + The objective is to verify that the data concerning the variants are well transmitted + even when passing through a modal window (product configurator). + + We create a product with the different attributes and we will modify them. + If the information is not correctly transmitted, + the default values of the variants will be used (the first one). + """ + + always_attribute, dynamic_attribute, never_attribute, never_attribute_custom = self.env['product.attribute'].create([ + { + 'name': 'Always attribute size', + 'display_type': 'radio', + 'create_variant': 'always' + }, + { + 'name': 'Dynamic attribute size', + 'display_type': 'radio', + 'create_variant': 'dynamic' + }, + { + 'name': 'Never attribute size', + 'display_type': 'radio', + 'create_variant': 'no_variant' + }, + { + 'name': 'Never attribute size custom', + 'display_type': 'radio', + 'create_variant': 'no_variant' + } + ]) + always_S, always_M, dynamic_S, dynamic_M, never_S, never_M, never_custom_no, never_custom_yes = self.env['product.attribute.value'].create([ + { + 'name': 'S always', + 'attribute_id': always_attribute.id, + }, + { + 'name': 'M always', + 'attribute_id': always_attribute.id, + }, + { + 'name': 'S dynamic', + 'attribute_id': dynamic_attribute.id, + }, + { + 'name': 'M dynamic', + 'attribute_id': dynamic_attribute.id, + }, + { + 'name': 'S never', + 'attribute_id': never_attribute.id, + }, + { + 'name': 'M never', + 'attribute_id': never_attribute.id, + }, + { + 'name': 'No never custom', + 'attribute_id': never_attribute_custom.id, + }, + { + 'name': 'Yes never custom', + 'attribute_id': never_attribute_custom.id, + 'is_custom': True, + } + ]) + + product_short = self.env['product.template'].create({ + 'name': 'Short (TEST)', + 'website_published': True, + }) + + self.env['product.template.attribute.line'].create([ + { + 'product_tmpl_id': product_short.id, + 'attribute_id': always_attribute.id, + 'value_ids': [(4, always_S.id), (4, always_M.id)], + }, + { + 'product_tmpl_id': product_short.id, + 'attribute_id': dynamic_attribute.id, + 'value_ids': [(4, dynamic_S.id), (4, dynamic_M.id)], + }, + { + 'product_tmpl_id': product_short.id, + 'attribute_id': never_attribute.id, + 'value_ids': [(4, never_S.id), (4, never_M.id)], + }, + { + 'product_tmpl_id': product_short.id, + 'attribute_id': never_attribute_custom.id, + 'value_ids': [(4, never_custom_no.id), (4, never_custom_yes.id)], + }, + ]) + + # Add an optional product to trigger the modal window + optional_product = self.env['product.template'].create({ + 'name': 'Optional product (TEST)', + 'website_published': True, + }) + product_short.optional_product_ids = [(4, optional_product.id)] + + old_sale_order = self.env['sale.order'].search([]) + self.start_tour("/", 'tour_variants_modal_window', login="demo") + + # Check the name of the created sale order line + 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')