Skip to content
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

[FIX] product_supplierinfo_for_customer: fix missing products in comodel search #25

Closed
wants to merge 1 commit into from

Conversation

xmglord
Copy link

@xmglord xmglord commented Sep 19, 2024

When searching for products in a comodel, the results are obtained via the _name_search method over product.product. Currently, this search is not retrieving all matching results.

This issue occurs because the parameters for the _name_search method changed in Odoo v17, and during the migration, this was not adapted. As a result, when the method is called, it only retrieves 100 results due to the default limit not being handled correctly.

This commit updates the overridden _name_search method to match the new method signature in Odoo v17 and properly handle the limit parameter. This ensures that all matching products are returned during the search.

…del search

When searching for products in a comodel, the results are obtained via
the `_name_search` method over `product.product`. Currently, this search
is not retrieving all matching results.

This issue occurs because the parameters for the `_name_search` method
changed in Odoo v17, and during the migration, this was not adapted. As
a result, when the method is called, it only retrieves 100 results due
to the default limit not being handled correctly.

This commit updates the overridden `_name_search` method to match the
new method signature in Odoo v17 and properly handle the `limit`
parameter. This ensures that all matching products are returned during
the search.
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.24%. Comparing base (594fe52) to head (8dd0e12).
Report is 622 commits behind head on 17.0.

Additional details and impacted files
@@            Coverage Diff             @@
##             17.0      #25      +/-   ##
==========================================
- Coverage   97.14%   95.24%   -1.90%     
==========================================
  Files           7      107     +100     
  Lines         105     1829    +1724     
  Branches        7      191     +184     
==========================================
+ Hits          102     1742    +1640     
- Misses          0       57      +57     
- Partials        3       30      +27     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@xmglord
Copy link
Author

xmglord commented Sep 19, 2024

@luisg123v

I explored the possibility of using the _rec_names_search property to avoid overriding the _name_search method. However, after analysis, I found that it's not feasible because a single product can have multiple product.customerinfo records, one for each customer.

While we can use dot notation and the @property decorator to reference related fields, Odoo's _rec_names_search property is not designed to handle searches over One2many relationships where multiple records need to be considered. Specifically, we cannot efficiently search across all product.customerinfo records associated with a product to match a search term in fields like product_code or product_name.

Given this limitation, the most effective solution is to fix the parameters of the overridden _name_search method to align with Odoo 17's changes.

@xmglord xmglord closed this Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants