Skip to content

Conversation

@antoniodavid
Copy link

No description provided.

[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
@antoniodavid antoniodavid force-pushed the 17.0-mig-hr_planning_resources branch from 549c4b4 to aab5f77 Compare February 5, 2025 04:28
@antoniodavid antoniodavid force-pushed the 17.0-mig-hr_planning_resources branch from aab5f77 to 411e569 Compare February 5, 2025 04:31
Copy link

@rrebollo rrebollo left a 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!

Comment on lines +6 to +7
5. In the task, if the "Force recalculation" checkbox is checked, all
hours that have elapsed will be calculated.
Copy link

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": "",
Copy link

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",
Copy link

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

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

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

Choose a reason for hiding this comment

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

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

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")),
Copy link

Choose a reason for hiding this comment

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

Suggested change
("task", _("Task")),
("task", "Task"),

You don't need to mark for translation selection labels


TASK_TYPES = [
("task", _("Task")),
("project", _("Project")),
Copy link

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")),
Copy link

Choose a reason for hiding this comment

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

idem

Copy link

@acsonefho acsonefho left a 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>

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(

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 🙏

Copy link
Member

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)

Copy link
Member

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):

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):

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"))

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

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
Copy link
Member

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",
)
Copy link
Member

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

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?

@dreispt
Copy link
Member

dreispt commented Jun 2, 2025

This app might have similar goals to the Shift Planning module started at OCA/hr#1473
This modules has as a design goal to be compatible with the EE Planning App.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants