Skip to content

Commit

Permalink
[ADD] hr_contract_update_overtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Shide committed Jul 11, 2024
1 parent c5a82e0 commit 3db3abf
Show file tree
Hide file tree
Showing 22 changed files with 1,025 additions and 0 deletions.
120 changes: 120 additions & 0 deletions hr_contract_update_overtime/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
================================
Update Overtime from HR Contract
================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:2329c25c16db2797a064fe7cbfc3513aea464555dc2d747d4ea77f8958d6dd05
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fhr--attendance-lightgray.png?logo=github
:target: https://github.com/OCA/hr-attendance/tree/16.0/hr_contract_update_overtime
: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-16-0/hr-attendance-16-0-hr_contract_update_overtime
: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=16.0
:alt: Try me on Runboat

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

This module extends the functionality of Contracts and Attendances to
support recalculating Overtime and to allow you to keep up to date your
Overtime.

You can Update Overtime in different ways:

- An action on the Contract History tree view
- Header button on Contract History form view
- Header button on Contract form view

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

Use Cases / Context
===================

This module was developed because in certain cases, you want to Update
Overtime of your Employees.

It will be useful for you if you activate contracts module after
attendance.

Usage
=====

To use this module, you need to:

1. Go to Settings > Attendances
2. Activate "Count Extra Hours"
3. Go to Employees > Contracts
4. Select any Contract History Running or Expired
5. Click on "Update Overtime" button on the Header

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_contract_update_overtime%0Aversion:%2016.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
-------

* Moduon

Contributors
------------

- Eduardo de Miguel (`Moduon <https://www.moduon.team/>`__)

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.

.. |maintainer-Shide| image:: https://github.com/Shide.png?size=40px
:target: https://github.com/Shide
:alt: Shide
.. |maintainer-rafaelbn| image:: https://github.com/rafaelbn.png?size=40px
:target: https://github.com/rafaelbn
:alt: rafaelbn

Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-Shide| |maintainer-rafaelbn|

This module is part of the `OCA/hr-attendance <https://github.com/OCA/hr-attendance/tree/16.0/hr_contract_update_overtime>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions hr_contract_update_overtime/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
28 changes: 28 additions & 0 deletions hr_contract_update_overtime/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2024 Moduon Team S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)

{
"name": "Update Overtime from HR Contract",
"summary": "Update Overtime from HR Contract",
"version": "16.0.1.0.0",
"development_status": "Alpha",
"category": "Human Resources/Contracts",
"website": "https://github.com/OCA/hr-attendance",
"author": "Moduon, Odoo Community Association (OCA)",
"maintainers": ["Shide", "rafaelbn"],
"license": "LGPL-3",
"application": False,
"installable": True,
"external_dependencies": {
"python": ["freezegun"],
},
"depends": [
"hr_contract",
"hr_attendance",
],
"data": [
"data/hr_contract_history_data.xml",
"views/hr_contract_history_view.xml",
"views/hr_contract_view.xml",
],
}
18 changes: 18 additions & 0 deletions hr_contract_update_overtime/data/hr_contract_history_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record
id="hr_contract_history_update_overtime_all_action"
model="ir.actions.server"
>
<field name="name">Update Overtime</field>
<field name="model_id" ref="hr_contract.model_hr_contract_history" />
<field name="binding_model_id" ref="hr_contract.model_hr_contract_history" />
<field name="binding_view_types">tree</field>
<field
name="groups_id"
eval="[(4, ref('hr_attendance.group_hr_attendance_user'))]"
/>
<field name="state">code</field>
<field name="code">records.action_update_overtime()</field>
</record>
</odoo>
40 changes: 40 additions & 0 deletions hr_contract_update_overtime/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_contract_update_overtime
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-07-11 08:46+0000\n"
"PO-Revision-Date: 2024-07-11 10:47+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.4.4\n"

#. module: hr_contract_update_overtime
#: model:ir.model,name:hr_contract_update_overtime.model_hr_contract
msgid "Contract"
msgstr "Contrato"

#. module: hr_contract_update_overtime
#: model:ir.model,name:hr_contract_update_overtime.model_hr_contract_history
msgid "Contract history"
msgstr "Histórico de contratación"

#. module: hr_contract_update_overtime
#: model:ir.actions.server,name:hr_contract_update_overtime.hr_contract_history_update_overtime_all_action
#: model_terms:ir.ui.view,arch_db:hr_contract_update_overtime.hr_contract_history_view_form
#: model_terms:ir.ui.view,arch_db:hr_contract_update_overtime.hr_contract_view_form
msgid "Update Overtime"
msgstr "Actualizar Horas Extra"

#. module: hr_contract_update_overtime
#: model_terms:ir.ui.view,arch_db:hr_contract_update_overtime.hr_contract_history_view_form
msgid "Update Overtime on Running and Expired contracts"
msgstr "Actualiza las Horas Extra en los contratos en Curso o Expirados"
38 changes: 38 additions & 0 deletions hr_contract_update_overtime/i18n/hr_contract_update_overtime.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_contract_update_overtime
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-07-11 08:46+0000\n"
"PO-Revision-Date: 2024-07-11 08:46+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: hr_contract_update_overtime
#: model:ir.model,name:hr_contract_update_overtime.model_hr_contract
msgid "Contract"
msgstr ""

#. module: hr_contract_update_overtime
#: model:ir.model,name:hr_contract_update_overtime.model_hr_contract_history
msgid "Contract history"
msgstr ""

#. module: hr_contract_update_overtime
#: model:ir.actions.server,name:hr_contract_update_overtime.hr_contract_history_update_overtime_all_action
#: model_terms:ir.ui.view,arch_db:hr_contract_update_overtime.hr_contract_history_view_form
#: model_terms:ir.ui.view,arch_db:hr_contract_update_overtime.hr_contract_view_form
msgid "Update Overtime"
msgstr ""

#. module: hr_contract_update_overtime
#: model_terms:ir.ui.view,arch_db:hr_contract_update_overtime.hr_contract_history_view_form
msgid "Update Overtime on Running and Expired contracts"
msgstr ""
2 changes: 2 additions & 0 deletions hr_contract_update_overtime/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import hr_contract
from . import hr_contract_history
27 changes: 27 additions & 0 deletions hr_contract_update_overtime/models/hr_contract.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2024 Moduon Team S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)
from datetime import datetime, timedelta

from odoo import fields, models


class HrContract(models.Model):
_inherit = "hr.contract"

def _get_attendances(self):
self.ensure_one()
dtt_start = datetime.combine(self.date_start, datetime.min.time())
dtt_end = datetime.combine(
self.date_end or fields.Date.today(), datetime.min.time()
)
return self.employee_id.attendance_ids.filtered(
lambda att: att.check_in >= dtt_start
and att.check_in < (dtt_end + timedelta(days=1))
)

def action_update_overtime(self):
for record in self:
if record.state not in {"open", "close"}:
continue

Check warning on line 25 in hr_contract_update_overtime/models/hr_contract.py

View check run for this annotation

Codecov / codecov/patch

hr_contract_update_overtime/models/hr_contract.py#L25

Added line #L25 was not covered by tests
attendances = record._get_attendances()
attendances._update_overtime()
10 changes: 10 additions & 0 deletions hr_contract_update_overtime/models/hr_contract_history.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright 2024 Moduon Team S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)
from odoo import models


class HrContractHistory(models.Model):
_inherit = "hr.contract.history"

def action_update_overtime(self):
return self.mapped("contract_ids").action_update_overtime()
4 changes: 4 additions & 0 deletions hr_contract_update_overtime/readme/CONTEXT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This module was developed because in certain cases, you want to
Update Overtime of your Employees.

It will be useful for you if you activate contracts module after attendance.
1 change: 1 addition & 0 deletions hr_contract_update_overtime/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Eduardo de Miguel ([Moduon](https://www.moduon.team/))
7 changes: 7 additions & 0 deletions hr_contract_update_overtime/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This module extends the functionality of Contracts and Attendances to support
recalculating Overtime and to allow you to keep up to date your Overtime.

You can Update Overtime in different ways:
- An action on the Contract History tree view
- Header button on Contract History form view
- Header button on Contract form view
7 changes: 7 additions & 0 deletions hr_contract_update_overtime/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
To use this module, you need to:

1. Go to Settings > Attendances
2. Activate "Count Extra Hours"
3. Go to Employees > Contracts
4. Select any Contract History Running or Expired
5. Click on "Update Overtime" button on the Header
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 3db3abf

Please sign in to comment.