-
-
Notifications
You must be signed in to change notification settings - Fork 750
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
[16.0][IMP] project_task_code: Allow search task by its code #1241
base: 16.0
Are you sure you want to change the base?
[16.0][IMP] project_task_code: Allow search task by its code #1241
Conversation
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 - LGTM!
7ed87a4
to
8b72058
Compare
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.
Code review LGTM
[FIX] project_task_code: fix called method name in tests
8b72058
to
0f5beaa
Compare
Hey @OCA/project-service-maintainers would be great to have this merged. Because absence of this feature affects the productivity badly 😉 |
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.
Generally OK, one question
|
||
@api.model | ||
def name_search(self, name, args=None, operator="ilike", limit=100): | ||
args = args or [] |
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.
What's the point of this line if args are just passed down?
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.
What's the point of this line if args are just passed down?
Args is used in super. As you see, I return combined results from super and from custom code-based domain search
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.
I see that it's used in super, I'm just curious why you'd need to make it empty list if it's defaulted to None. I think super is capable of handling None as well, as that's the default signature of name_search, no?
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.
I see that it's used in super, I'm just curious why you'd need to make it empty list if it's defaulted to None. I think super is capable of handling None as well, as that's the default signature of name_search, no?
Yeah, you're right, this line is pointless, I'll remove it. Thanks for the review!
@api.model | ||
def name_search(self, name, args=None, operator="ilike", limit=100): | ||
args = args or [] | ||
domain = [("code", operator, name)] |
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.
You need to add a check to see if the name field is not empty.
Because of this, additional values are thrown up during the search
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
@dmitriypaulov please squash the commits into one |
I think the technical implementation is incorrect. |
def name_search(self, name, args=None, operator="ilike", limit=100): | ||
result = [] | ||
|
||
if name: | ||
domain = [("code", operator, name)] | ||
tasks = self.search(domain, limit=limit) | ||
result = tasks.name_get() | ||
|
||
return ( | ||
super().name_search(name, args=args, operator=operator, limit=limit) | ||
+ result | ||
) |
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.
Just expand the domain with the additional search condition.
Suggested pseudocode:
def name_search(self, name, args=None, operator="ilike", limit=100): | |
result = [] | |
if name: | |
domain = [("code", operator, name)] | |
tasks = self.search(domain, limit=limit) | |
result = tasks.name_get() | |
return ( | |
super().name_search(name, args=args, operator=operator, limit=limit) | |
+ result | |
) | |
def _name_search(self, name, args=None, operator="ilike", limit=100, name_get_uid=None): | |
new_args = expression.OR([args or [], [("code", operator, name)]]) | |
return super()._name_search(name, new_args, operator, limit, name_get_uid) |
This feature allows users to search project tasks by their codes