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

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

Merged
merged 1 commit into from
Sep 23, 2024

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.

@xmglord xmglord changed the title [FIX] product_supplierinfo_for_customer: fix missing products in como… [FIX] product_supplierinfo_for_customer: fix missing products in comodel search Sep 19, 2024
@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
Copy link
Author

xmglord commented Sep 19, 2024

@pedrobaeza @luisg123v please review

@pedrobaeza pedrobaeza added this to the 17.0 milestone Sep 19, 2024
Copy link
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get this change, as the signature is the previous one:

https://github.com/odoo/odoo/blob/4401d4f9af7698ee79aee82bda3b240ef322bf43/odoo/models.py#L1714

@xmglord
Copy link
Author

xmglord commented Sep 19, 2024

I don't get this change, as the signature is the previous one:

https://github.com/odoo/odoo/blob/4401d4f9af7698ee79aee82bda3b240ef322bf43/odoo/models.py#L1714

The inheritance is over this one:

https://github.com/odoo/odoo/blob/4401d4f9af7698ee79aee82bda3b240ef322bf43/odoo/models.py#L1750

And the change is because in the replanishment (or any other model with a field related to product.product) if you search for a product it will only take into account the first hundred products which is not expected.

Copy link
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, sorry, I lost the initial _.

@luisg123v
Copy link

Hi @xmglord,

LGTM.

Could we take this chance to add myself as maintainer, please?

Regards,

@xmglord xmglord force-pushed the 17.0-fix_search-xmglord branch 2 times, most recently from aca3e4e to 98be2f9 Compare September 19, 2024 23:15
@xmglord
Copy link
Author

xmglord commented Sep 19, 2024

Hi @xmglord,

LGTM.

Could we take this chance to add myself as maintainer, please?

Regards,

Done, also I test again the dot notation and the error was a typo, but it do not work using _rec_name_search since it used in _name_search in here but there's an inheritance in odoo that do not use the model property in here so it will not be possible to use.

@xmglord xmglord force-pushed the 17.0-fix_search-xmglord branch 2 times, most recently from 36147b1 to a731c7a Compare September 19, 2024 23:44
…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
Copy link

@luisg123v luisg123v left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

CC @desdelinux @moylop260

Copy link
Contributor

@marielejeune marielejeune left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Could we merge this so I can take it into the 18.0 migration I'm working on?

@xmglord
Copy link
Author

xmglord commented Sep 23, 2024

@pedrobaeza this is ready for merge

@pedrobaeza pedrobaeza changed the title [FIX] product_supplierinfo_for_customer: fix missing products in comodel search [17.0][FIX] product_supplierinfo_for_customer: fix missing products in comodel search Sep 23, 2024
@pedrobaeza
Copy link
Member

/ocabot merge patch

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 17.0-ocabot-merge-pr-1725-by-pedrobaeza-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit bbba9d8 into OCA:17.0 Sep 23, 2024
6 of 7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 61513e5. Thanks a lot for contributing to OCA. ❤️

@luisg123v luisg123v deleted the 17.0-fix_search-xmglord branch September 23, 2024 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants