[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) <thle@odoo.com>
This commit is contained in:
Thomas Lefebvre (thle)
2023-03-28 10:30:06 +02:00
parent ca5ca24bc6
commit 54ffd01b07
3 changed files with 111 additions and 111 deletions
-111
View File
@@ -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')
@@ -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')