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

[16.0][IMP] project_task_code: Allow search task by its code #1241

Open
wants to merge 2 commits into
base: 16.0
Choose a base branch
from

Conversation

dmitriypaulov
Copy link

This feature allows users to search project tasks by their codes

Copy link

@Aldeigja Aldeigja left a comment

Choose a reason for hiding this comment

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

Functional - LGTM!

@dmitriypaulov dmitriypaulov force-pushed the 16.0-t3197-project_task_code-search_task_code branch 7 times, most recently from 7ed87a4 to 8b72058 Compare February 26, 2024 15:30
Copy link
Member

@ivs-cetmix ivs-cetmix left a 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
@dmitriypaulov dmitriypaulov force-pushed the 16.0-t3197-project_task_code-search_task_code branch from 8b72058 to 0f5beaa Compare February 29, 2024 09:00
@ivs-cetmix
Copy link
Member

Hey @OCA/project-service-maintainers would be great to have this merged. Because absence of this feature affects the productivity badly 😉

Copy link
Contributor

@alexey-pelykh alexey-pelykh left a 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 []
Copy link
Contributor

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?

Copy link
Author

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

Copy link
Contributor

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?

Copy link
Author

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)]
Copy link

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

Copy link

@DemchukM DemchukM left a comment

Choose a reason for hiding this comment

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

LGTM

@alexey-pelykh
Copy link
Contributor

@dmitriypaulov please squash the commits into one

@dreispt
Copy link
Sponsor Member

dreispt commented Mar 22, 2024

I think the technical implementation is incorrect.
You should inject an additional search domain tuple rather than overriding name_search...

Comment on lines +46 to +57
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
)
Copy link
Sponsor Member

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:

Suggested change
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)

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.

None yet

7 participants