Skip to content

Commit

Permalink
[MIG] website_sale_product_attribute_value_filter_existing: Migration…
Browse files Browse the repository at this point in the history
… to 17.0
  • Loading branch information
lef-adhoc committed Jun 19, 2024
1 parent b9ad056 commit 5e39b07
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 50 deletions.
Original file line number Diff line number Diff line change
@@ -1,43 +1,40 @@
/** @odoo-module **/

import tour from "web_tour.tour";
import {registry} from "@web/core/registry";

tour.register(
"website_sale_product_attribute_value_filter_existing",
{
registry
.category("web_tour.tours")
.add("website_sale_product_attribute_value_filter_existing", {
test: true,
url: "/shop",
},
// No product has the yellow colour attribute defined.
// When enter to "/shop" the attribute "test yellow" should not appear in the list of filters by attribute.
[
// For the following steps it is checked that the attribute "test yellow" is
// not present in the list but the attributes "test red", "test blue" and
// "test green" must be present.
{
content:
"Search a product. Ensure 'test red', 'test blue' and 'test green' attributes are present while 'Test yellow' is not.",
trigger: "form input[name=search]",
run: "text desk",
extra_trigger:
".js_attributes:not(:contains('Test yellow')):has(label:contains('Test red')), .js_attributes:not(:contains('Test yellow')):has(label:contains('Test blue')), .js_attributes:not(:contains('Test yellow')):has(label:contains('Test green'))",
},
{
content:
"Submit search button. Ensure 'test red', 'test blue' and 'test green' attributes are present while 'Test yellow' is not.",
trigger: 'form:has(input[name="search"]) .oe_search_button',
extra_trigger:
".js_attributes:not(:contains('Test yellow')):has(label:contains('Test red')), .js_attributes:not(:contains('Test yellow')):has(label:contains('Test blue')), .js_attributes:not(:contains('Test yellow')):has(label:contains('Test green'))",
},
// After searching, the attributes "test red" and "test green" must be present.
// "Test yelow" should not be present as it is not used in any product and
// "test blue" should not be present as it is not used in the products shown.
{
content:
"Go to /shop after the search. Ensure 'test red' and 'test green' attributes are present while 'Test yellow' and 'test blue' are not.",
trigger: "a[href='/shop']",
extra_trigger:
".js_attributes:not(:contains('Test blue'), :contains('Test yellow')):has(label:contains('Test green')), .js_attributes:not(:contains('Test blue'), :contains('Test yellow')):has(label:contains('Test red'))",
},
]
);
steps: () => [
// No product has the yellow colour attribute defined.
// When enter to "/shop" the attribute "test yellow" should not appear in the list of filters by attribute.
// For the following steps it is checked that the attribute "test yellow" is
// not present in the list but the attributes "test red", "test blue" and
// "test green" must be present.
{
content:
"Ensure 'test red', 'test blue' and 'test green' attributes are present while 'Test yellow' is not.",
trigger: "body",
extra_trigger:
".js_attributes:not(:contains('Test yellow')):has(label:contains('Test red')), .js_attributes:not(:contains('Test yellow')):has(label:contains('Test blue')), .js_attributes:not(:contains('Test yellow')):has(label:contains('Test green'))",
},
{
content: "Selecting the 'test green' attribute.",
trigger:
".form-check:has(label:contains('Test green')) input[type='checkbox']",
run: "click",
},
// After selecting, the attributes "test red" and "test green" must be present.
// "Test yellow" should not be present as it is not used in any product and
// "test blue" should not be present as it is not used in the products shown.
{
content:
"Ensure 'test red' and 'test green' attributes are present while 'Test yellow' and 'test blue' are not.",
trigger: "body",
extra_trigger:
".js_attributes:not(:contains('Test blue')):not(:contains('Test yellow')):has(label:contains('Test green')), .js_attributes:not(:contains('Test blue')):not(:contains('Test yellow')):has(label:contains('Test red'))",
},
],
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,31 @@
<!-- Copyright 2019 Tecnativa - Victor M.M. Torres
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<odoo>
<template id="products_attributes" inherit_id="website_sale.products_attributes">
<template id="products_attributes" inherit_id="website_sale.products_attributes">
<xpath
expr="//t[@t-if=&quot;a.display_type == 'select'&quot;]//t[@t-foreach='a.value_ids']/option"
position="attributes"
>
<attribute name="t-if">attr_values_used &amp; v</attribute>
</xpath>
<xpath
expr="//t[@t-if=&quot;a.display_type == 'radio' or a.display_type == 'pills'&quot;]//t[@t-foreach='a.value_ids']/div"
expr="//div[@t-elif=&quot;a.display_type in ('radio', 'pills', 'multi')&quot;]//t[@t-foreach='a.value_ids']/div"
position="attributes"
>
<attribute name="t-if">attr_values_used &amp; v</attribute>
</xpath>
<xpath
expr="//div[@t-if=&quot;a.display_type == 'color'&quot;]//t[@t-foreach='a.value_ids']/label"
position="attributes"
>
</template>
<template
id="o_wsale_offcanvas_color_attribute"
inherit_id="website_sale.o_wsale_offcanvas_color_attribute"
>
<xpath expr="//t[@t-foreach='a.value_ids']/label" position="attributes">
<attribute name="t-if">attr_values_used &amp; v</attribute>
</xpath>
</template>
<template id="o_wsale_offcanvas" inherit_id="website_sale.o_wsale_offcanvas">
<xpath expr="//div[@t-foreach='a.value_ids']/div" position="attributes">
<attribute name="t-if">attr_values_used &amp; v</attribute>
</xpath>
<xpath
expr="//div[@t-if=&quot;a.display_type == 'color'&quot;]//t[@t-foreach='a.value_ids']/label"
position="attributes"
>
<attribute name="t-if">attr_values_used &amp; v</attribute>
</xpath>
</template>
</odoo>

0 comments on commit 5e39b07

Please sign in to comment.