-
Notifications
You must be signed in to change notification settings - Fork 41
[IMP] beesdoo_shift: add name_get on task_template #302
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: 12.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,39 @@ def subscribe(self): | |
| return res | ||
|
|
||
|
|
||
| class TaskTemplate(models.Model): | ||
| _inherit = "beesdoo.shift.template" | ||
|
|
||
| def name_get(self): | ||
| res = [] | ||
| for rec in self: | ||
| name = "%s %s %s (%s-%s)" % ( | ||
| rec.name, | ||
| rec.planning_id.name, | ||
| rec.day_nb_id.name, | ||
| float_to_time(rec.start_time), | ||
| float_to_time(rec.end_time) | ||
| ) | ||
| res.append((rec.id, name)) | ||
| return res | ||
|
|
||
| @api.model | ||
| def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None): | ||
| domain = [] | ||
| time_domain = [] | ||
| FIELDS = ['planning_id', 'name', 'day_nb_id'] | ||
| for n in name.split(" "): | ||
| if re.search(r"^\(\d{2}:\d{2}-\d{2}:\d{2}\)$", n): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you provide an example(s) of matched pattern for readability ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good to know, thanks! |
||
| start, end = n[1:-1].split('-') | ||
| start, end = time_to_float(start), time_to_float(end) | ||
| time_domain = [['&', ('start_time', '=', start), ('end_time', '=', end)]] | ||
| elif n.startswith('('): # Ignore missformed hour | ||
| continue | ||
| else: | ||
| domain.append(expression.OR([[(f, 'ilike', n)] for f in FIELDS])) | ||
| return self.search(expression.AND(domain + time_domain)).name_get() | ||
|
|
||
|
|
||
| class Task(models.Model): | ||
| _inherit = "beesdoo.shift.shift" | ||
|
|
||
|
|
||
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.
We try to use more explicit names in our loops, such as
for template in self:orfor shift_template in self:. Don't you use that at Odoo ?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.