[FIX] website_sale, product: fix tags view and filter

- fix tag filter
- fix product_product view in sales
- fix add to cart animation
- impove product tag view in website_sale and product

closes odoo/odoo#129901

Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
This commit is contained in:
Valeriya(vchu)
2023-07-28 14:53:50 +02:00
parent baea0cac48
commit 8f8271abe5
5 changed files with 91 additions and 40 deletions
+18 -13
View File
@@ -8,19 +8,25 @@
<form string="Product Tag">
<sheet>
<group>
<group>
<field name="name"/>
<field name="color" widget="color"/>
</group>
</group>
<group>
<field name="product_template_ids" widget="many2many_tags"/>
<field name="product_product_ids" widget="many2many_tags"/>
<field name="product_ids"
widget="many2many_tags"
attrs="{'invisible': [('product_ids', '=', [])]}"
/>
<field name="name"/>
</group>
<notebook>
<page string="Product Templates">
<field name="product_template_ids"
context="{'tree_view_ref':'product.product_template_view_tree_tag'}"
/>
</page>
<page string="Product Variants">
<field name="product_product_ids"
context="{'tree_view_ref':'product.product_product_view_tree_tag'}"
/>
</page>
<page string="All Products" attrs="{'invisible': [('product_ids', '=', [])]}">
<field name="product_ids"
context="{'tree_view_ref':'product.product_product_view_tree_tag'}"
/>
</page>
</notebook>
</sheet>
</form>
</field>
@@ -33,7 +39,6 @@
<field name="name"/>
<field name="product_template_ids" widget="many2many_tags" optional="show"/>
<field name="product_product_ids" widget="many2many_tags" string="Product Variant" optional="show"/>
<field name="color" widget="color" readonly="1" optional="hide"/>
</tree>
</field>
</record>
+34 -11
View File
@@ -82,11 +82,8 @@
</span>
</div>
<field name="categ_id" string="Product Category"/>
<label for="product_tag_ids"/>
<div>
<field name="product_tag_ids" widget="many2many_tags" class="oe_inline" context="{'product_template_id': id}"/>
<button name="%(product_tag_action)d" icon="oi-arrow-right" title="Tags" type="action" class="btn-link"/>
</div>
<field name="product_tag_ids" widget="many2many_tags" context="{'product_template_id': id}"/>
<button name="%(product_tag_action)d" icon="oi-arrow-right" type="action" class="btn-link ps-0" colspan="2" string="Configure tags"/>
<field name="company_id" groups="base.group_multi_company"
options="{'no_create': True}"/>
<field name="currency_id" invisible="1"/>
@@ -288,11 +285,8 @@
</group>
<group name="tags" string="Tags">
<field name="product_tag_ids" widget="many2many_tags" readonly="1"/>
<label for="additional_product_tag_ids"/>
<div>
<field name="additional_product_tag_ids" widget="many2many_tags" class="oe_inline" context="{'product_variant_id': id}"/>
<button name="%(product_tag_action)d" icon="oi-arrow-right" title="Tags" type="action" class="btn-link"/>
</div>
<field name="additional_product_tag_ids" widget="many2many_tags" context="{'product_variant_id': id}"/>
<button name="%(product_tag_action)d" icon="oi-arrow-right" type="action" class="btn-link ps-0" colspan="2" string="Configure tags"/>
</group>
</group>
<group>
@@ -356,6 +350,35 @@
</field>
</record>
<record model="ir.ui.view" id="product_template_view_tree_tag">
<field name="name">product.template.view.tree.tag</field>
<field name="model">product.template</field>
<field name="arch" type="xml">
<tree string="Product Templates" editable="bottom">
<field name="name" readonly="1"/>
<field name="default_code" readonly="1" optional="show"/>
<field name="description" readonly="1" optional="show"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="product_product_view_tree_tag">
<field name="name">product.product.view.tree.tag</field>
<field name="model">product.product</field>
<field name="arch" type="xml">
<tree string="Product Variants" editable="bottom">
<field name="name" readonly="1"/>
<field name="default_code" readonly="1" optional="show"/>
<field name="product_template_variant_value_ids"
widget="many2many_tags"
groups="product.group_product_variant"
readonly="1"
/>
<field name="description" readonly="1" optional="show"/>
</tree>
</field>
</record>
<record id="product_normal_form_view" model="ir.ui.view">
<field name="name">product.product.form</field>
<field name="model">product.product</field>
@@ -397,7 +420,7 @@
<attribute name="options">{'no_open': true}</attribute>
</field>
<field name="product_tag_ids" position="after">
<field name="additional_product_tag_ids"/>
<field name="additional_product_tag_ids" widget="many2many_tags"/>
</field>
</field>
</record>
+12 -5
View File
@@ -324,11 +324,6 @@ class WebsiteSale(http.Controller):
else:
post['tags'] = None
tags = {}
ProductTag = request.env['product.tag']
all_tags = ProductTag.search(
[('product_ids.is_published', '=', True), ('visible_on_ecommerce', '=', True)]
+ website_domain
)
keep = QueryURL('/shop', **self._shop_get_query_url_kwargs(category and int(category), search, min_price, max_price, **post))
@@ -398,6 +393,18 @@ class WebsiteSale(http.Controller):
max_price = max_price if max_price >= available_min_price else available_max_price
post['max_price'] = max_price
if filter_by_tags_enabled:
if (
search_product.product_tag_ids
or search_product.product_variant_ids.additional_product_tag_ids
):
ProductTag = request.env['product.tag']
all_tags = ProductTag.search(
[('product_ids.is_published', '=', True), ('visible_on_ecommerce', '=', True)]
+ website_domain
)
else:
all_tags = []
categs_domain = [('parent_id', '=', False)] + website_domain
if search:
search_categories = Category.search(
+26 -10
View File
@@ -7,13 +7,20 @@
<field name="model">product.tag</field>
<field name="inherit_id" ref="product.product_tag_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='color']/.." position="after">
<group>
<field name="visible_on_ecommerce"/>
</group>
</xpath>
<field name="color" position="after">
<field name="image" widget="image" options="{'size': [0, 55]}"/>
<field name="name" position="after">
<field name="visible_on_ecommerce"/>
<field name="color"
widget='color'
attrs="{'invisible': [('visible_on_ecommerce', '=', False)]}"
/>
<field name="image"
widget="image"
options="{'size': [0, 55]}"
attrs="{'invisible': [('visible_on_ecommerce', '=', False)]}"
/>
<p class="text-muted" colspan="2" attrs="{'invisible': [('visible_on_ecommerce', '=', False)]}">
If an image is set, the color will not be used on eCommerce.
</p>
</field>
</field>
</record>
@@ -25,9 +32,18 @@
<field name="arch" type="xml">
<field name="name" position="after">
<field name="visible_on_ecommerce" optional="show"/>
</field>
<field name="color" position="after">
<field name="image" widget="image" options="{'size': [0, 30]}" optional="hide"/>
<field name="color"
widget="color"
optional="hide"
readonly="1"
attrs="{'invisible': [('visible_on_ecommerce', '=', False)]}"
/>
<field name="image"
widget="image"
options="{'size': [0, 30]}"
optional="hide"
attrs="{'invisible': [('visible_on_ecommerce', '=', False)]}"
/>
</field>
</field>
</record>
@@ -121,7 +121,7 @@ publicWidget.registry.WebsiteSale.include({
$quantity.parent().parent().removeClass('d-none');
$quantity.text(quantity).hide().fadeIn(600);
// find the closest div that has an img tag in it
const imgContainerEl = self.$form.closest('div:has(img)');
const imgContainerEl = self.$form.closest('div:has(.o_wsale_product_images)');
wsUtils.animateClone($('header .o_wsale_my_cart').first(), imgContainerEl, 25, 40);
sessionStorage.setItem('website_sale_cart_quantity', quantity);
}).then(()=>{