[FIX] website_sale: not use t-if on attribute of snippet section

Before this commit the default product category was set on the product
snippet by a wrong use of qweb's <attribute> tag, trying to use t-if to
only apply the change for product snippet.
This actually was ignored and the attribute was appearing on all dropped
dynamic snippets (including blogs).

After this commit the default product category is set on the product
snippet from javascript.

https://github.com/odoo/odoo/pull/68529
This commit is contained in:
Benoit Socias
2021-03-30 13:53:54 +00:00
parent 862dc45f56
commit 4396439f27
2 changed files with 8 additions and 6 deletions
@@ -63,7 +63,14 @@ const dynamicSnippetProductsOptions = s_dynamic_snippet_carousel_options.extend(
const productCategoriesSelectorEl = uiFragment.querySelector('[data-name="product_category_opt"]');
return this._renderSelectUserValueWidgetButtons(productCategoriesSelectorEl, this.productCategories);
},
/**
* @override
* @private
*/
_setOptionsDefaultValues: function () {
this._setOptionValue('productCategoryId', 'all');
this._super.apply(this, arguments);
},
});
options.registry.dynamic_snippet_products = dynamicSnippetProductsOptions;
@@ -5,11 +5,6 @@
<t t-set="snippet_name" t-value="'s_dynamic_snippet_products'"/>
</t>
</template>
<template id="s_dynamic_snippet_template" inherit_id="website.s_dynamic_snippet_template">
<xpath expr="section" position="attributes">
<attribute t-if="snippet_name == 's_dynamic_snippet_products'" name="data-product-category-id">all</attribute>
</xpath>
</template>
<template id="s_dynamic_snippet_products_options" inherit_id="website.snippet_options">
<xpath expr="." position="inside">
<t t-call="website.dynamic_snippet_carousel_options_template">