Skip to content

Conversation

@chrisduvivier
Copy link
Contributor

Prior to this commit, flexible resources did not have their leaves reflected as gray cells in the planning gantt view. This was due to the work_intervals being ignored for the calculation of flexible resources availability.

This commit adds measures to handle the leaves for flexible resources by setting a dummy attendance (which covers the whole length of the period in gantt interval), and then injects their leaves interval.

To replicate:

  1. set a timeoff to a flexible resource
  2. open planning app
  3. in the gantt view, the day in which the timeoff was set should be grayed.

ticket-id: 4492625
enterprise: 79532

Description of the issue/feature this PR addresses:

Current behavior before PR:

Desired behavior after PR is merged:


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@robodoo
Copy link
Contributor

robodoo commented Feb 17, 2025

Pull request status dashboard

@C3POdoo C3POdoo requested a review from a team February 17, 2025 17:00
@C3POdoo C3POdoo added the RD research & development, internal work label Feb 17, 2025
@chrisduvivier chrisduvivier force-pushed the 18.0-fix-planning-handle-flexible-leave-in-gantt-duch branch 3 times, most recently from 1f7aef1 to 2191951 Compare February 18, 2025 16:06
Copy link
Contributor

@xavierbol xavierbol left a comment

Choose a reason for hiding this comment

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

Thanks for your work, I left some comments but I have not tested it yet.

@chrisduvivier chrisduvivier force-pushed the 18.0-fix-planning-handle-flexible-leave-in-gantt-duch branch 2 times, most recently from db83eff to 8ae2004 Compare February 20, 2025 10:31
@C3POdoo C3POdoo requested a review from a team February 20, 2025 10:37
@chrisduvivier chrisduvivier force-pushed the 18.0-fix-planning-handle-flexible-leave-in-gantt-duch branch from 8ae2004 to e3cfdaa Compare February 20, 2025 14:10
@C3POdoo C3POdoo requested review from a team, Gorash and rco-odoo and removed request for a team February 20, 2025 14:13
@chrisduvivier chrisduvivier changed the title [FIX] resource: fix flexible resource leave in planning gantt [FIX] hr, hr_holidays, resource: fix flexible resource leave in planning gantt Feb 20, 2025
@chrisduvivier chrisduvivier force-pushed the 18.0-fix-planning-handle-flexible-leave-in-gantt-duch branch from e3cfdaa to 3b9fb40 Compare February 20, 2025 16:14
Copy link
Contributor

@tivisse tivisse left a comment

Choose a reason for hiding this comment

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

Small review + incoming commit

@chrisduvivier chrisduvivier force-pushed the 18.0-fix-planning-handle-flexible-leave-in-gantt-duch branch 5 times, most recently from 4459be1 to fddcf72 Compare March 14, 2025 16:04
Copy link
Contributor

@xavierbol xavierbol left a comment

Choose a reason for hiding this comment

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

Thanks for your work, I left one comment. 🙂

@chrisduvivier chrisduvivier force-pushed the 18.0-fix-planning-handle-flexible-leave-in-gantt-duch branch 2 times, most recently from 616b6e8 to 3aa0b8f Compare March 18, 2025 15:54
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably ensure having at most one record, otherwise this will crash

Copy link
Contributor

Choose a reason for hiding this comment

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

prout

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review @Bertrand2 , I added self.ensure_one() to ensure the behavior you suggested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nevermind, adding ensure_one broke on multiple places since the method was called from an empty self (by calling the class self.env['resource.calendar']._get_attendance_intervals_days_data(...), I opted to add len(self) == 1 on the line itself.

@chrisduvivier chrisduvivier force-pushed the 18.0-fix-planning-handle-flexible-leave-in-gantt-duch branch from 3aa0b8f to c02b449 Compare March 20, 2025 14:22
Prior to this commit, flexible resources did not have their leaves
reflected as gray cells in the planning gantt view. This was due to the
work_intervals being ignored for the calculation of flexible resources
availability.

This commit adds measures to handle the leaves for flexible resources by
setting a dummy attendance (which covers the whole length of the period
in gantt interval), and then injects their leaves interval.

To replicate:
1. set a timeoff to a flexible resource
2. open planning app
3. in the gantt view, the day in which the timeoff was set should be grayed.

ticket-id: 4492625
enterprise: 79532
…ing wrong arg

Prior to this test, calendar attendance_intervals_batch was getting resources records
of type 'resource.test' when it is expected to get 'resource.resource' as its argument.
This fix was introduced with the changes introduced in attendarce_intervals to adapt to
the creation of dummy attendance interval for flexible resources in the task below.

related-task: 4492625
tivisse and others added 2 commits March 20, 2025 16:58
…_schedule

This commit aims to fix the issue where the _get_schedule method of the
hr.calendar model was receiving a list of employee ids instead of a list
of resource objects, leading to some test failures as '_is_flexible' method
was not accessible from the employee object that was initially passed.

Additionally, the _get_schedule method in res_partner was passing employee_id
instead of the employee's resource_id to fetch the calendar_intervals. This was
also fixed in this commit.

related ticket-id: 4492625
enterprise: 79532
Prior to this commit, _get_calendars used to return the company default working calendar for
fully flexible resources (ones without a calendar). This lead to _get_attendance_intervals_days_data
to fail to fetch duration_days and duration_hours for such resources, leading to zero division.

Additionally, _get_leave_days_data_batch is adapted to handle fully flexible resources by returning
days and hours of the whole period without leaves take into account (as we currently do not support
leaves for fully flexible).
@chrisduvivier chrisduvivier force-pushed the 18.0-fix-planning-handle-flexible-leave-in-gantt-duch branch from c02b449 to 3e2bca3 Compare March 20, 2025 15:58
@xavierbol
Copy link
Contributor

robodoo r+ rebase-ff

@robodoo
Copy link
Contributor

robodoo commented Mar 21, 2025

Merge method set to rebase and fast-forward.

robodoo pushed a commit that referenced this pull request Mar 21, 2025
Prior to this commit, flexible resources did not have their leaves
reflected as gray cells in the planning gantt view. This was due to the
work_intervals being ignored for the calculation of flexible resources
availability.

This commit adds measures to handle the leaves for flexible resources by
setting a dummy attendance (which covers the whole length of the period
in gantt interval), and then injects their leaves interval.

To replicate:
1. set a timeoff to a flexible resource
2. open planning app
3. in the gantt view, the day in which the timeoff was set should be grayed.

Ticket-id: 4492625
Enterprise: 79532
Part-of: #198032
Related: odoo/enterprise#79532
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
robodoo pushed a commit that referenced this pull request Mar 21, 2025
…ing wrong arg

Prior to this test, calendar attendance_intervals_batch was getting resources records
of type 'resource.test' when it is expected to get 'resource.resource' as its argument.
This fix was introduced with the changes introduced in attendarce_intervals to adapt to
the creation of dummy attendance interval for flexible resources in the task below.

Related-task: 4492625
Part-of: #198032
Related: odoo/enterprise#79532
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
robodoo pushed a commit that referenced this pull request Mar 21, 2025
…_schedule

This commit aims to fix the issue where the _get_schedule method of the
hr.calendar model was receiving a list of employee ids instead of a list
of resource objects, leading to some test failures as '_is_flexible' method
was not accessible from the employee object that was initially passed.

Additionally, the _get_schedule method in res_partner was passing employee_id
instead of the employee's resource_id to fetch the calendar_intervals. This was
also fixed in this commit.

related ticket-id: 4492625

Enterprise: 79532
Part-of: #198032
Related: odoo/enterprise#79532
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
@robodoo robodoo closed this in 093d5b2 Mar 21, 2025
omar-sherif9992 pushed a commit to odoo-dev/odoo that referenced this pull request Mar 26, 2025
Prior to this commit, flexible resources did not have their leaves
reflected as gray cells in the planning gantt view. This was due to the
work_intervals being ignored for the calculation of flexible resources
availability.

This commit adds measures to handle the leaves for flexible resources by
setting a dummy attendance (which covers the whole length of the period
in gantt interval), and then injects their leaves interval.

To replicate:
1. set a timeoff to a flexible resource
2. open planning app
3. in the gantt view, the day in which the timeoff was set should be grayed.

Ticket-id: 4492625
Enterprise: 79532
Part-of: odoo#198032
Related: odoo/enterprise#79532
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
omar-sherif9992 pushed a commit to odoo-dev/odoo that referenced this pull request Mar 26, 2025
…ing wrong arg

Prior to this test, calendar attendance_intervals_batch was getting resources records
of type 'resource.test' when it is expected to get 'resource.resource' as its argument.
This fix was introduced with the changes introduced in attendarce_intervals to adapt to
the creation of dummy attendance interval for flexible resources in the task below.

Related-task: 4492625
Part-of: odoo#198032
Related: odoo/enterprise#79532
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
omar-sherif9992 pushed a commit to odoo-dev/odoo that referenced this pull request Mar 26, 2025
…_schedule

This commit aims to fix the issue where the _get_schedule method of the
hr.calendar model was receiving a list of employee ids instead of a list
of resource objects, leading to some test failures as '_is_flexible' method
was not accessible from the employee object that was initially passed.

Additionally, the _get_schedule method in res_partner was passing employee_id
instead of the employee's resource_id to fetch the calendar_intervals. This was
also fixed in this commit.

related ticket-id: 4492625

Enterprise: 79532
Part-of: odoo#198032
Related: odoo/enterprise#79532
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
omar-sherif9992 pushed a commit to odoo-dev/odoo that referenced this pull request Mar 26, 2025
Prior to this commit, _get_calendars used to return the company default working calendar for
fully flexible resources (ones without a calendar). This lead to _get_attendance_intervals_days_data
to fail to fetch duration_days and duration_hours for such resources, leading to zero division.

Additionally, _get_leave_days_data_batch is adapted to handle fully flexible resources by returning
days and hours of the whole period without leaves take into account (as we currently do not support
leaves for fully flexible).

closes odoo#198032

Related: odoo/enterprise#79532
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
gamarino pushed a commit to numaes/numa-public-odoo that referenced this pull request Mar 27, 2025
Prior to this commit, flexible resources did not have their leaves
reflected as gray cells in the planning gantt view. This was due to the
work_intervals being ignored for the calculation of flexible resources
availability.

This commit adds measures to handle the leaves for flexible resources by
setting a dummy attendance (which covers the whole length of the period
in gantt interval), and then injects their leaves interval.

To replicate:
1. set a timeoff to a flexible resource
2. open planning app
3. in the gantt view, the day in which the timeoff was set should be grayed.

Ticket-id: 4492625
Enterprise: 79532
Part-of: odoo/odoo#198032
Related: odoo/enterprise#79532
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
gamarino pushed a commit to numaes/numa-public-odoo that referenced this pull request Mar 27, 2025
…ing wrong arg

Prior to this test, calendar attendance_intervals_batch was getting resources records
of type 'resource.test' when it is expected to get 'resource.resource' as its argument.
This fix was introduced with the changes introduced in attendarce_intervals to adapt to
the creation of dummy attendance interval for flexible resources in the task below.

Related-task: 4492625
Part-of: odoo/odoo#198032
Related: odoo/enterprise#79532
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
gamarino pushed a commit to numaes/numa-public-odoo that referenced this pull request Mar 27, 2025
…_schedule

This commit aims to fix the issue where the _get_schedule method of the
hr.calendar model was receiving a list of employee ids instead of a list
of resource objects, leading to some test failures as '_is_flexible' method
was not accessible from the employee object that was initially passed.

Additionally, the _get_schedule method in res_partner was passing employee_id
instead of the employee's resource_id to fetch the calendar_intervals. This was
also fixed in this commit.

related ticket-id: 4492625

Enterprise: 79532
Part-of: odoo/odoo#198032
Related: odoo/enterprise#79532
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
gamarino pushed a commit to numaes/numa-public-odoo that referenced this pull request Mar 27, 2025
Prior to this commit, _get_calendars used to return the company default working calendar for
fully flexible resources (ones without a calendar). This lead to _get_attendance_intervals_days_data
to fail to fetch duration_days and duration_hours for such resources, leading to zero division.

Additionally, _get_leave_days_data_batch is adapted to handle fully flexible resources by returning
days and hours of the whole period without leaves take into account (as we currently do not support
leaves for fully flexible).

closes odoo/odoo#198032

Related: odoo/enterprise#79532
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
@fw-bot fw-bot deleted the 18.0-fix-planning-handle-flexible-leave-in-gantt-duch branch March 28, 2025 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RD research & development, internal work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants