- 
                Notifications
    
You must be signed in to change notification settings  - Fork 30.3k
 
[FW][FIX] website_sale: use correct limit when filtering newest products #199331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Closed
      
      
            fw-bot
  wants to merge
  1
  commit into
  odoo:saas-18.2
from
odoo-dev:saas-18.2-saas-17.4-opw-4302856-correctly_apply_limit_when_searching_newest_products-sile-418735-fw
  
      
      
   
      
    
                
     Closed
            
            
          Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    | 
           This PR targets saas-18.2 and is part of the forward-port chain. Further PRs will be created up to master. More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port  | 
    
9367539    to
    e0ebdd5      
    Compare
  
    | 
           robodoo r+  | 
    
e0ebdd5    to
    f261883      
    Compare
  
    Versions -------- - saas-17.4+ Steps ----- 1. Create a new product with a lot of variants; 2. publish it to the website; 3. edit the website home page to add a product carousel; 4. set it to display newest products & hide variants. Issue ----- Fewer than 16 products are displayed in the carousel. Cause ----- Unlike the other product filters handled in 2249939, the "Newest Products" filter is defined in `data/data.xml`, and stored as a record. This means it doesn't use the `_get_products` method to perform the search, instead using the `_prepare_values` method from the `website` module. For obvious reasons, the method defined in `website` doesn't take the `hide_variants` parameter into account to get the correct amount of search results. Instead it passes 16 `product.product` records to the `_filter_records_to_values` override in `website_sale`, where duplicate templates are filtered out, resulting in fewer than 16 product templates. Solution -------- When calling `super()._prepare_values` for stored `product.product` filters, temporarily square the usual limit for the search, and filter reduce to size later. This may still be inadequate when working with products with dozens of variants, but should cover most normal use cases without requiring drastic changes to filter templates or search domain in stable. On master, we could add a new filter specifically for `product.template`. opw-4302856 X-original-commit: 116e615
f261883    to
    ef575ce      
    Compare
  
    | 
           robodoo r+  | 
    
| 
           @lvsz @Feyensv staging failed: ci/runbot on 229139cf9f6b4c787b799b49f0961107470d8592 (view more at https://runbot.odoo.com/runbot/build/75870818)  | 
    
| 
           robodoo retry  | 
    
    
  robodoo 
      pushed a commit
      that referenced
      this pull request
    
      Mar 3, 2025 
    
    
      
  
    
      
    
  
Versions -------- - saas-17.4+ Steps ----- 1. Create a new product with a lot of variants; 2. publish it to the website; 3. edit the website home page to add a product carousel; 4. set it to display newest products & hide variants. Issue ----- Fewer than 16 products are displayed in the carousel. Cause ----- Unlike the other product filters handled in 2249939, the "Newest Products" filter is defined in `data/data.xml`, and stored as a record. This means it doesn't use the `_get_products` method to perform the search, instead using the `_prepare_values` method from the `website` module. For obvious reasons, the method defined in `website` doesn't take the `hide_variants` parameter into account to get the correct amount of search results. Instead it passes 16 `product.product` records to the `_filter_records_to_values` override in `website_sale`, where duplicate templates are filtered out, resulting in fewer than 16 product templates. Solution -------- When calling `super()._prepare_values` for stored `product.product` filters, temporarily square the usual limit for the search, and filter reduce to size later. This may still be inadequate when working with products with dozens of variants, but should cover most normal use cases without requiring drastic changes to filter templates or search domain in stable. On master, we could add a new filter specifically for `product.template`. opw-4302856 closes #199331 X-original-commit: 116e615 Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com> Signed-off-by: Levi Siuzdak <sile@odoo.com>
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      Labels
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Versions
Steps
Issue
Fewer than 16 products are displayed in the carousel.
Cause
Unlike the other product filters handled in #189040, the "Newest Products" filter is defined in
data/data.xml, and stored as a record.This means it doesn't use the
_get_productsmethod to perform the search, instead using the_prepare_valuesmethod from thewebsitemodule.For obvious reasons, the method defined in
websitedoesn't take thehide_variantsparameter into account to get the correct amount of search results:odoo/addons/website/models/website_snippet_filter.py
Lines 102 to 108 in 0f64298
Instead it passes 16
product.productrecords to the_filter_records_to_valuesoverride inwebsite_sale, where duplicate templates are filtered out, resulting in fewer than 16 product templates:odoo/addons/website_sale/models/website_snippet_filter.py
Lines 73 to 76 in 0f64298
Solution
When calling
super()._prepare_valuesfor storedproduct.productfilters, temporarily square the usual limit for the search, and filter reduce to size later.This may still be inadequate when working with products with dozens of variants, but should cover most normal use cases without requiring drastic changes to filter templates or search domain in stable.
On master, we could add a new filter specifically for
product.template.opw-4302856
Forward-Port-Of: #195857