Skip to content

Commit

Permalink
[ADD] hr_timesheet_overtime_begin_end
Browse files Browse the repository at this point in the history
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
  • Loading branch information
carmenbianca committed Sep 16, 2024
1 parent faf9def commit b0b445e
Show file tree
Hide file tree
Showing 16 changed files with 652 additions and 20 deletions.
7 changes: 0 additions & 7 deletions hr_timesheet_overtime_rate/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ At time of writing (2024-06-28), the way a rate is computed for a date is by
looking _exclusively_ at the corresponding day of the week. This should be more
robust.

Because ``unit_amount`` is computed from ``hours_worked``, this module is not
compatible with ``hr_timesheet_begin_end``. To make this module subsequently
compatible with ``hr_timesheet_begin_end``, ``hours_worked`` must be computed
from ``time_stop`` and ``time_start``, and ``unit_amount`` must use this
module's computation method instead of ``hr_timesheet_begin_end``'s. The
compatibility layer should go into its own module.

Furthermore, the summary view of timesheet sheets are set read-only in this
module. Because of programming complexities, it is not easy to change this view
to use ``hours_worked`` instead of ``unit_amount``.
Expand Down
7 changes: 0 additions & 7 deletions hr_timesheet_overtime_rate/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ At time of writing (2024-06-28), the way a rate is computed for a date is by
looking _exclusively_ at the corresponding day of the week. This should be more
robust.

Because ``unit_amount`` is computed from ``hours_worked``, this module is not
compatible with ``hr_timesheet_begin_end``. To make this module subsequently
compatible with ``hr_timesheet_begin_end``, ``hours_worked`` must be computed
from ``time_stop`` and ``time_start``, and ``unit_amount`` must use this
module's computation method instead of ``hr_timesheet_begin_end``'s. The
compatibility layer should go into its own module.

Furthermore, the summary view of timesheet sheets are set read-only in this
module. Because of programming complexities, it is not easy to change this view
to use ``hours_worked`` instead of ``unit_amount``.
6 changes: 0 additions & 6 deletions hr_timesheet_overtime_rate/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,6 @@ <h1><a class="toc-backref" href="#toc-entry-1">Known issues / Roadmap</a></h1>
<p>At time of writing (2024-06-28), the way a rate is computed for a date is by
looking _exclusively_ at the corresponding day of the week. This should be more
robust.</p>
<p>Because <tt class="docutils literal">unit_amount</tt> is computed from <tt class="docutils literal">hours_worked</tt>, this module is not
compatible with <tt class="docutils literal">hr_timesheet_begin_end</tt>. To make this module subsequently
compatible with <tt class="docutils literal">hr_timesheet_begin_end</tt>, <tt class="docutils literal">hours_worked</tt> must be computed
from <tt class="docutils literal">time_stop</tt> and <tt class="docutils literal">time_start</tt>, and <tt class="docutils literal">unit_amount</tt> must use this
module’s computation method instead of <tt class="docutils literal">hr_timesheet_begin_end</tt>’s. The
compatibility layer should go into its own module.</p>
<p>Furthermore, the summary view of timesheet sheets are set read-only in this
module. Because of programming complexities, it is not easy to change this view
to use <tt class="docutils literal">hours_worked</tt> instead of <tt class="docutils literal">unit_amount</tt>.</p>
Expand Down
70 changes: 70 additions & 0 deletions hr_timesheet_overtime_rate_begin_end/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
===========================================================
Timesheet - Overtime rate and begin/end hours compatibility
===========================================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:5ab790e671629b45c0297eceb50037e97ab4827da3d637687db534dd0dd0dde0
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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-coopiteasy%2Fcie--timesheet-lightgray.png?logo=github
:target: https://github.com/coopiteasy/cie-timesheet/tree/16.0/hr_timesheet_overtime_rate_begin_end
:alt: coopiteasy/cie-timesheet

|badge1| |badge2| |badge3|

Make ``hr_timesheet_overtime_rate`` and ``hr_timesheet_begin_end`` compatible.

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/coopiteasy/cie-timesheet/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/coopiteasy/cie-timesheet/issues/new?body=module:%20hr_timesheet_overtime_rate_begin_end%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
~~~~~~~

* Coop IT Easy SC

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

* `Coop IT Easy SC <https://coopiteasy.be>`_:

* Carmen Bianca BAKKER

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

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

Current maintainer:

|maintainer-carmenbianca|

This module is part of the `coopiteasy/cie-timesheet <https://github.com/coopiteasy/cie-timesheet/tree/16.0/hr_timesheet_overtime_rate_begin_end>`_ project on GitHub.

You are welcome to contribute.
5 changes: 5 additions & 0 deletions hr_timesheet_overtime_rate_begin_end/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-FileCopyrightText: 2024 Coop IT Easy SC
#
# SPDX-License-Identifier: AGPL-3.0-or-later

from . import models
20 changes: 20 additions & 0 deletions hr_timesheet_overtime_rate_begin_end/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# SPDX-FileCopyrightText: 2024 Coop IT Easy SC
#
# SPDX-License-Identifier: AGPL-3.0-or-later

{
"name": "Timesheet - Overtime rate and begin/end hours compatibility",
"summary": "Make ``hr_timesheet_overtime_rate`` and ``hr_timesheet_begin_end`` compatible.",
"version": "16.0.1.0.0",
"category": "Human Resources",
"website": "https://github.com/coopiteasy/cie-timesheet",
"author": "Coop IT Easy SC",
"maintainers": ["carmenbianca"],
"license": "AGPL-3",
"application": False,
"depends": [
"hr_timesheet_overtime_rate",
"hr_timesheet_begin_end",
],
"auto_install": True,
}
5 changes: 5 additions & 0 deletions hr_timesheet_overtime_rate_begin_end/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-FileCopyrightText: 2024 Coop IT Easy SC
#
# SPDX-License-Identifier: AGPL-3.0-or-later

from . import account_analytic_line
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# SPDX-FileCopyrightText: 2024 Coop IT Easy SC
#
# SPDX-License-Identifier: AGPL-3.0-or-later

from odoo import api, fields, models


class AnalyticLine(models.Model):
_inherit = "account.analytic.line"

hours_worked = fields.Float(
store=True,
readonly=True,
compute="_compute_hours_worked",
)
unit_amount = fields.Float(
# Make sure unit_amount is computed from hours worked, NOT directly from
# time_start and time_stop.
compute="_compute_unit_amount_from_hours",
)

@api.depends("time_start", "time_stop")
def _compute_hours_worked(self):
for line in self:
line.hours_worked = self._hours_from_start_stop(
line.time_start, line.time_stop
)

# Add date to constrains.
@api.constrains("time_start", "time_stop", "unit_amount", "date")
def _check_time_start_stop(self):
return super()._check_time_start_stop()

def unit_amount_from_start_stop(self):
result = super().unit_amount_from_start_stop()
result *= self.rate_for_date(self.date)
return result
3 changes: 3 additions & 0 deletions hr_timesheet_overtime_rate_begin_end/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Coop IT Easy SC <https://coopiteasy.be>`_:

* Carmen Bianca BAKKER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make ``hr_timesheet_overtime_rate`` and ``hr_timesheet_begin_end`` compatible.
Loading

0 comments on commit b0b445e

Please sign in to comment.