-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[19.0][MIG] base_name_search_improved: Migration to 19.0 #3381
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
base: 19.0
Are you sure you want to change the base?
[19.0][MIG] base_name_search_improved: Migration to 19.0 #3381
Conversation
f88ae89 to
56e83be
Compare
baf-adhoc
left a comment
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.
Functional review ok
|
@bizzappdev Could you check this PR #3357 ? |
56e83be to
bdeac98
Compare
lef-adhoc
left a comment
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.
LGTM
|
This PR has the |
|
LGTM |
ced-adhoc
left a comment
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.
LGTM
| seen_ids = {res[0] for res in original_results} | ||
| remaining_limit = limit - len(original_results) if limit else None | ||
| smart_results = Base.name_search( | ||
| self, name=name, args=args, operator=operator, limit=remaining_limit |
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.
this should be
def _register_hook(self):
def make_smart_name_search(original_name_search):
def wrapper(
self, name="", domain=None, operator="ilike", limit=100, **kwargs
):
original_results = original_name_search(
self, name, domain, operator, limit, **kwargs
)
if not name or (limit and len(original_results) >= limit):
return original_results
seen_ids = {res[0] for res in original_results}
remaining_limit = limit - len(original_results) if limit else None
smart_results = Base.name_search(
self, name=name, domain=domain, operator=operator, limit=remaining_limit
)
additional_results = [
(res_id, res_name)
for res_id, res_name in smart_results
if res_id not in seen_ids
]
return original_results + additional_results
Odoo 19.0 introduced a breaking change in the name_search() method signature across all models:
Odoo ≤18.0: name_search(self, name="", args=None, operator="ilike", limit=100)
Odoo 19.0: name_search(self, name="", domain=None, operator="ilike", limit=100)
The parameter args was renamed to domain for consistency with other Odoo API methods.
The module fails in Odoo 19.0 with the error:
TypeError: Base.name_search() got an unexpected keyword argument 'domain'
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.
@bizzappdev Hi! I just want to ask you if you could see my review.
Thanks in advance!
bdeac98 to
ebda477
Compare
ced-adhoc
left a comment
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.
LGTM
| ): | ||
| original_results = original_name_search( | ||
| self, name, domain, operator, limit, **kwargs | ||
| ) |
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.
This should be:
original_results = original_name_search(
self, name=name, domain=domain, operator=operator, limit=limit, **kwargs
)
In Odoo 19, name_search signature changed from args to domain. Using named arguments ensures parameters are passed correctly regardless of the method signature and how Python unpacks arguments internally. This makes the code more robust and compatible across different Odoo versions and decorators.
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.
@bizzappdev Hi! I want to ask you if you have seen my review. Thanks!
ebda477 to
b4dea29
Compare
- Descriptor: change __openerp__.py file to __manifest__.py also update module
version from 9.0.1.0.0 to 11.0.1.0.0
- Update README using guideline
- Views: replace view tag openerp to odoo and rename files to match guideline
- Models
- update imports from openerp to odoo
- remove enconding line # -*- coding: utf-8 -*-
- update to make it compatible
- remove use of SUPERUSER_ID use sudo instead.
- rename class name to make it match with guideline.
- update methods to match api used in version 11.0
- fix pylint errors
- replace use of non exist self._model with self._name
- use `Model `is not None instead of if `Model` this becuase the last one is
a empty recordset and this one was evaluate to False and never was
patching the method.
- apply changes resquested/suggested in the PR by the reviewers.
Currently translated at 94.4% (17 of 18 strings) Translation: server-tools-14.0/server-tools-14.0-base_name_search_improved Translate-URL: https://translation.odoo-community.org/projects/server-tools-14-0/server-tools-14-0-base_name_search_improved/it/
and avoid superself variable
Translate Spanish texts to English
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: server-tools-16.0/server-tools-16.0-base_name_search_improved Translate-URL: https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-base_name_search_improved/
Currently translated at 100.0% (25 of 25 strings) Translation: server-tools-16.0/server-tools-16.0-base_name_search_improved Translate-URL: https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-base_name_search_improved/es/
Currently translated at 36.0% (9 of 25 strings) Translation: server-tools-16.0/server-tools-16.0-base_name_search_improved Translate-URL: https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-base_name_search_improved/it/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: server-tools-16.0/server-tools-16.0-base_name_search_improved Translate-URL: https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-base_name_search_improved/
When applying monkey patches, we want to skip abstract models because patching those may mess up the inheritance. An example of this is ir.model which is assigned the studio mixin using inherit = ['studio.mixin', 'ir.model']. If the mixin itself is patched, and the method is overridden once again (in, say, enterprise 15's documents_spreadsheet), the super() method called in that override is the patched version of studio.mixin rather than the override of ir.model in the base module, which is now skipped entirely.
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: server-tools-18.0/server-tools-18.0-base_name_search_improved Translate-URL: https://translation.odoo-community.org/projects/server-tools-18-0/server-tools-18-0-base_name_search_improved/
… wrapper This refactor ensures the smart search functionality works reliably across all models, including those with custom search logic like `product.product`. Instead of being overridden, this module now uses a startup hook to wrap the existing `name_search`. This new approach merges results from the original search with the smart search, providing a richer, more consistent user experience.
Currently translated at 96.0% (24 of 25 strings) Translation: server-tools-18.0/server-tools-18.0-base_name_search_improved Translate-URL: https://translation.odoo-community.org/projects/server-tools-18-0/server-tools-18-0-base_name_search_improved/tr/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: server-tools-18.0/server-tools-18.0-base_name_search_improved Translate-URL: https://translation.odoo-community.org/projects/server-tools-18-0/server-tools-18-0-base_name_search_improved/
…t_search In v18 `_search_smart_search` was delegating to `name_search`. This introduces an artificial limit (100 records) before other domain filters are applied, leading to incomplete results. This PR restores the original behavior from v16: - Build the domain directly in `_search_smart_search`. This makes smart search consistent again with standard search and avoids missing records.
b4dea29 to
5ed79ca
Compare
No description provided.