-
-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] hr_attendance_report_theoretical_time: Migration to 18.0
- Loading branch information
1 parent
4f61f34
commit 20d1be4
Showing
9 changed files
with
73 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,13 +17,13 @@ Theoretical vs Attended Time Analysis | |
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fhr--attendance-lightgray.png?logo=github | ||
:target: https://github.com/OCA/hr-attendance/tree/17.0/hr_attendance_report_theoretical_time | ||
:target: https://github.com/OCA/hr-attendance/tree/18.0/hr_attendance_report_theoretical_time | ||
:alt: OCA/hr-attendance | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/hr-attendance-17-0/hr-attendance-17-0-hr_attendance_report_theoretical_time | ||
:target: https://translation.odoo-community.org/projects/hr-attendance-18-0/hr-attendance-18-0-hr_attendance_report_theoretical_time | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/hr-attendance&target_branch=17.0 | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/hr-attendance&target_branch=18.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
@@ -129,7 +129,7 @@ Bug Tracker | |
Bugs are tracked on `GitHub Issues <https://github.com/OCA/hr-attendance/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/hr-attendance/issues/new?body=module:%20hr_attendance_report_theoretical_time%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
`feedback <https://github.com/OCA/hr-attendance/issues/new?body=module:%20hr_attendance_report_theoretical_time%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
|
@@ -156,6 +156,7 @@ Contributors | |
- `Trobz <https://trobz.com>`__: | ||
|
||
- Dzung Tran <[email protected]> | ||
- Do Anh Duy <[email protected]> | ||
|
||
Other credits | ||
------------- | ||
|
@@ -181,6 +182,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose | |
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
This module is part of the `OCA/hr-attendance <https://github.com/OCA/hr-attendance/tree/17.0/hr_attendance_report_theoretical_time>`_ project on GitHub. | ||
This module is part of the `OCA/hr-attendance <https://github.com/OCA/hr-attendance/tree/18.0/hr_attendance_report_theoretical_time>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
hr_attendance_report_theoretical_time/models/resource_calendar.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright 2024 Janik von Rotz <[email protected]> | ||
# Copyright 2024 Camptocamp | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import models | ||
|
||
from odoo.addons.resource.models.resource_resource import Intervals | ||
|
||
|
||
class ResourceCalendar(models.Model): | ||
_inherit = "resource.calendar" | ||
|
||
def _attendance_intervals_batch_exclude_public_holidays( | ||
self, start_dt, end_dt, intervals, resources, tz | ||
): | ||
partner_id = self.env.context.get("partner_id", False) | ||
if not partner_id: | ||
employee_id = self.env.context.get("employee_id", False) | ||
if employee_id: | ||
employee = self.env["hr.employee"].browse(employee_id) | ||
partner_id = employee.address_id.id | ||
list_by_dates = ( | ||
self.env["hr.holidays.public"] | ||
.get_holidays_list( | ||
start_dt=start_dt.date(), | ||
end_dt=end_dt.date(), | ||
partner_id=partner_id, | ||
) | ||
.mapped("date") | ||
) | ||
for resource in resources: | ||
interval_resource = intervals[resource.id] | ||
attendances = [] | ||
for attendance in interval_resource._items: | ||
if attendance[0].date() not in list_by_dates: | ||
attendances.append(attendance) | ||
intervals[resource.id] = Intervals(attendances) | ||
return intervals | ||
return super()._attendance_intervals_batch_exclude_public_holidays( | ||
start_dt, end_dt, intervals, resources, tz | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
- Aritz Olea \<<[email protected]>\> | ||
- [Trobz](https://trobz.com): | ||
- Dzung Tran \<<[email protected]>\> | ||
- Do Anh Duy \<<[email protected]>\> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters