Skip to content

Commit

Permalink
Merge PR #140 into 15.0
Browse files Browse the repository at this point in the history
Signed-off-by OSevangelist
  • Loading branch information
OCA-git-bot committed Jun 3, 2024
2 parents 83a82e1 + aa82e19 commit 449971b
Show file tree
Hide file tree
Showing 29 changed files with 1,468 additions and 0 deletions.
74 changes: 74 additions & 0 deletions hr_attendance_contract_missing_days/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
==============================================================
Attendance generation for missing days with installed contract
==============================================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
: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/15.0/hr_attendance_contract_missing_days
: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-15-0/hr_attendance-15-0-hr_attendance_contract_missing_days
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/hr_attendance&target_branch=15.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This modules changes the generation of the attendances for the missing days to use the
HR contracts accordingly.

**Table of contents**

.. contents::
:local:

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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/hr_attendance/issues/new?body=module:%20hr_attendance_contract_missing_days%0Aversion:%2015.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.

Credits
=======

Authors
~~~~~~~

* initOS GmbH

Contributors
~~~~~~~~~~~~

* initOS GmbH (initOS.com)

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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/15.0/hr_attendance_contract_missing_days>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions hr_attendance_contract_missing_days/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# © 2023 initOS GmbH
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
19 changes: 19 additions & 0 deletions hr_attendance_contract_missing_days/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# © 2023 initOS GmbH
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Attendance generation for missing days with installed contract",
"version": "15.0.1.0.0",
"category": "Hidden",
"author": "initOS GmbH, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/hr-attendance",
"license": "AGPL-3",
"summary": "This modules combines the generation of attendances for working "
"days without attendance with HR contracts",
"depends": [
"hr_contract",
"hr_attendance_missing_days",
],
"auto_install": True,
"installable": True,
}
4 changes: 4 additions & 0 deletions hr_attendance_contract_missing_days/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# © 2023 initOS GmbH
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import hr_employee
32 changes: 32 additions & 0 deletions hr_attendance_contract_missing_days/models/hr_employee.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# © 2023 initOS GmbH
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from datetime import datetime, time

import pytz

from odoo import models


class Employee(models.Model):
_inherit = "hr.employee"

def _get_work_intervals_batch(self, dt_from, dt_to):
intervals = []

tz = pytz.timezone(self.tz or "UTC")
for contract in self._get_contracts(dt_from, dt_to, states=["open", "close"]):
start = datetime.combine(contract.date_start, time.min)
start = max(dt_from, tz.localize(start).astimezone(pytz.UTC))

if contract.date_end:
end = datetime.combine(contract.date_end, time.max)
end = min(dt_to, tz.localize(end).astimezone(pytz.UTC))
else:
end = dt_to

intervals.extend(
contract.resource_calendar_id._work_intervals_batch(start, end)[False]
)

return intervals
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* initOS GmbH (initOS.com)
2 changes: 2 additions & 0 deletions hr_attendance_contract_missing_days/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This modules changes the generation of the attendances for the missing days to use the
HR contracts accordingly.
Loading

0 comments on commit 449971b

Please sign in to comment.