-
-
Notifications
You must be signed in to change notification settings - Fork 4
[17.0][MIG] hr_planning_resources #5
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: 17.0
Are you sure you want to change the base?
Conversation
[16.0][ADD] hr_planning_resources [REF][16.0] hr_planning_resources: Refactoring app [16.0][ADD] hr_planning_resources: Add readme [16.0][ADD] hr_planning_resources: Add test-requirements Revert "[16.0][ADD] hr_planning_resources: Add readme" This reverts commit 4073ee9. [16.0][IMP] hr_planning_resources: Refactoring app
549c4b4 to
aab5f77
Compare
aab5f77 to
411e569
Compare
rrebollo
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.
First of all, great work! Thank you for your contribution—I really appreciate your efforts. I've shared a few suggestions for your consideration; please feel free to address them as you see fit.
There is one suggestion in particular that I believe could significantly impact the current code: separating the logic for the helpdesk integration. In my opinion, this approach brings valuable benefits—one of them being a smaller scope for this review. 😄
Before proceeding further with my review, I’d love to hear your thoughts on this. Would you be open to making that change? That way, I can conduct the review once.
Thanks again for your contribution—this looks very promising!
| 5. In the task, if the "Force recalculation" checkbox is checked, all | ||
| hours that have elapsed will be calculated. |
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.
Could you clarify this a little more?
| @@ -0,0 +1,33 @@ | |||
| { | |||
| "name": "HR Resource Planner", | |||
| "summary": "", | |||
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.
Please add a summary
| "depends": [ | ||
| "project", | ||
| "web_timeline", | ||
| "helpdesk_mgmt", |
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.
My suggestion is to move helpdesk integration to another addon.
| "project.project": [("project_id", "=", self.id)], | ||
| "helpdesk.ticket": [("ticket_id", "=", self.id)], | ||
| } | ||
| domain = domain_map.get(self._name, [("task_id", "=", self.id)]) |
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 think prefixing task_id (obviously this should be done in field definition) with hr_ will be better. task_id collide with the built-in project.task immediately in my thoughts.
|
|
||
| from odoo import _, api, fields, models | ||
| from odoo.exceptions import ValidationError | ||
| from odoo.tools.date_utils import get_timedelta |
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.
👍 for using helper date utils, nice
| return datetime.combine(fields.Date.context_today(self), time.min) | ||
|
|
||
| def _default_date_end(self): | ||
| return datetime.combine(fields.Date.context_today(self), time.max) |
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.
| return datetime.combine(fields.Date.context_today(self), time.max) | |
| return fields.Datetime.end_of(fields.Date.context_today(self), 'day') |
| return datetime.combine(fields.Date.context_today(self), time.max) | ||
|
|
||
| def _get_default_employee(self): | ||
| return self.env["hr.employee"].search([("user_id", "=", self.env.uid)], limit=1) |
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 think you should match active company in this domain too
| from odoo import _, api, fields, models | ||
|
|
||
| TASK_TYPES = [ | ||
| ("task", _("Task")), |
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.
| ("task", _("Task")), | |
| ("task", "Task"), |
You don't need to mark for translation selection labels
|
|
||
| TASK_TYPES = [ | ||
| ("task", _("Task")), | ||
| ("project", _("Project")), |
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.
idem
| TASK_TYPES = [ | ||
| ("task", _("Task")), | ||
| ("project", _("Project")), | ||
| ("ticket", _("Ticket")), |
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.
idem
acsonefho
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.
Nice job! 💪
Sorry but I didn't finish the review but I put some comments :)
| @@ -0,0 +1,22 @@ | |||
| <?xml version="1.0" encoding="UTF-8" ?> | |||
| <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.
Should be noupdate="1"
|
|
||
| def _compute_hr_task_count(self): | ||
| for record in self: | ||
| ticket_count = self.env["hr.task"].search_count( |
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.
Please use read_group (before the for) to do only a single query 🙏
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.
Or add a task_ids o2m and then you can just do ticket_count = len(record.task_ids)
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.
Also, consider moving this to a separate glue module with the Helpdesk app.
You don't want to force that app on the users.
|
|
||
| @api.model_create_multi | ||
| def create(self, vals_list): | ||
| if self.env.context.get("default_user_id", False): |
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 context key should already put this value (on the form view) as a default. And maybe the user change it (and you re-force it?)
| return time.strftime(get_lang(env).time_format) | ||
|
|
||
|
|
||
| def format_date(env, date): |
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 already have this kind of tool into Odoo:
fields.Date.to_string(...)
fields.Date.from_string(...)
fields.Datetime.to_string(...)
fields.Datetime.from_string(...)
| def localize(date): | ||
| return ( | ||
| utc.localize(date) | ||
| .astimezone(timezone(self.env.user.tz or "UTC")) |
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 already have fields.Datetime.context_timestamp(...) who is doing a part of your code
| return ( | ||
| self.env.user.tz | ||
| or self.employee_id.tz | ||
| or self.employee_id.tz |
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.
duplicates
| @@ -0,0 +1,2 @@ | |||
| from . import models | |||
| from . import wizard | |||
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.
Remember the singular naming convention for module names.
This should probably be hr_planning_resource.
| ("date_to", ">=", date_from), | ||
| ], | ||
| order="date_from", | ||
| ) |
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.
Preferably you have a method just to build and return the domain, and then do the search in the main business logic, instead of already returning the recordset.
Doing so is more friendly to extensions.
| ) | ||
|
|
||
| def _group_leaves_by_employee(self, calendar_leaves, employee_ids): | ||
| leaves = defaultdict(list) |
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.
Can't leaves be a recordset?
|
This app might have similar goals to the Shift Planning module started at OCA/hr#1473 |
No description provided.