Skip to content

Commit

Permalink
[FIX] website_sale: invalid cache
Browse files Browse the repository at this point in the history
product prices are dependent of so many factors (taxes, pricelist, fiscal position, ...)
that caching them is either wrong or unproductive (because of the complexity of the cache to manage).

This commit removes this specific cache.
A dedicated performance review is done in the same PR to make sure
the performance is optimized as much as possible.

Part-of: odoo#142860
  • Loading branch information
Feyensv committed Nov 28, 2023
1 parent 4f582ee commit 540872d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion addons/website_sale/views/templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@
<div class="mb16" id="category_header" t-att-data-editor-message="editor_msg" t-field="category.website_description"/>
</t>

<div t-cache="pricelist,fiscal_position,products" t-if="products" class="o_wsale_products_grid_table_wrapper pt-3 pt-lg-0">
<div t-if="products" class="o_wsale_products_grid_table_wrapper pt-3 pt-lg-0">
<table class="table table-borderless h-100 m-0" t-att-data-ppg="ppg" t-att-data-ppr="ppr" t-att-data-default-sort="website.shop_default_sort" t-att-data-name="grid_block_name">
<colgroup t-ignore="true">
<!-- Force the number of columns (useful when only one row of (x < ppr) products) -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@

<template id="add_to_wishlist" inherit_id="website_sale.products_item" name="Wishlist Button" priority="20">
<xpath expr="//div[hasclass('o_wsale_product_btn')]" position="inside">
<t t-nocache="The wishlist depends on the user and must not be shared with other users. As this rendering is in the loop, the product value is set in the template, we must retain the id of the product on which we are."
t-nocache-product_template_id="product.id">
<t t-set="product" t-value="products.filtered(lambda p: p.id == product_template_id)"/>
<t t-set="in_wish" t-value="product._is_in_wishlist()"/>
<t t-set="product_variant_id" t-value="product._get_first_possible_variant_id()"/>
<button t-if="product_variant_id" type="button" role="button" class="btn btn-outline-primary bg-white o_add_wishlist" t-att-disabled='in_wish or None' title="Add to Wishlist" t-att-data-product-template-id="product.id" t-att-data-product-product-id="product_variant_id" data-action="o_wishlist"><span class="fa fa-heart" role="img" aria-label="Add to wishlist"></span></button>
</t>
<t t-set="in_wish" t-value="product._is_in_wishlist()"/>
<t t-set="product_variant_id" t-value="product._get_first_possible_variant_id()"/>
<button t-if="product_variant_id"
type="button"
role="button"
class="btn btn-outline-primary bg-white o_add_wishlist"
t-att-disabled='in_wish or None' title="Add to Wishlist"
t-att-data-product-template-id="product.id"
t-att-data-product-product-id="product_variant_id"
data-action="o_wishlist">
<span class="fa fa-heart" role="img" aria-label="Add to wishlist"/>
</button>
</xpath>
</template>

Expand Down

0 comments on commit 540872d

Please sign in to comment.