-
Notifications
You must be signed in to change notification settings - Fork 0
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][MIG] website_sale_product_search_advanced #11
base: 17.0
Are you sure you want to change the base?
[17.0][MIG] website_sale_product_search_advanced #11
Conversation
Great, at last Odoo made a proper hook for this!!! I'll test it ASAP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments
@api.model | ||
def _search_get_detail(self, website, order, options): | ||
res = super()._search_get_detail(website, order, options) | ||
res['search_fields'].append('barcode') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Locally tested, when any result is obtained seems to be 👍 , but when no results were found, in internal error is raised looking for similar results:
You can try this very interesting "similar results" functionality searching with a not exact word like "florr" instead of "floor", with this addon uninstalled.
Error is raised in those cases because Odoo looks via Postgres SQL raw query for a similar result... and barcode is actually a field of product.product model, not template (see https://github.com/odoo/odoo/blob/b6b90636938ae961c339807ea893cabdede9f549/addons/product/models/product_template.py#L130 and https://github.com/odoo/odoo/blob/b6b90636938ae961c339807ea893cabdede9f549/addons/product/models/product_product.py#L44-L46). This fixes it:
res['search_fields'].append('barcode') | |
res['search_fields'].append('product_variant_ids.barcode') |
def _search_get_detail(self, website, order, options): | ||
res = super()._search_get_detail(website, order, options) | ||
res['search_fields'].append('barcode') | ||
res['search_fields'].append('website_partner_ref') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In original _search_get_detail code you can see that not only desired fields are added to search_fields
key, but also to mapping
clause (not sure which is the need), and even in fetch_fields
(in some cases, indeed). Could you investigate a little but about those keys and their usage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- search_fields: fields within which the search term must be found
- fetch_fields: fields from which data must be fetched
e2c78a6
to
a18e8b2
Compare
@dalonsod Change search method in v17.... Its most simple but it was hard search it