Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[12.0][MIG] hr_timesheet_overtime_rate_begin_end #38

Open
wants to merge 7 commits into
base: 12.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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_begin_end
:alt: coopiteasy/cie-timesheet

|badge1| |badge2| |badge3|

Make the two modules 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_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_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
21 changes: 21 additions & 0 deletions hr_timesheet_overtime_rate_begin_end/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# SPDX-FileCopyrightText: 2024 Coop IT Easy SC
#
# SPDX-License-Identifier: AGPL-3.0-or-later

{
"name": "Timesheet - Overtime and begin/end hours compatibility",
"summary": """
Make the two modules compatible.""",
"version": "12.0.1.0.0",
"category": "Human Resources",
"website": "https://coopiteasy.be",
"author": "Coop IT Easy SC",
"maintainers": ["carmenbianca"],
"license": "AGPL-3",
"application": False,
"depends": [
"hr_timesheet_overtime",
"hr_timesheet_activity_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,39 @@
# SPDX-FileCopyrightText: 2024 Coop IT Easy SC
#
# SPDX-License-Identifier: AGPL-3.0-or-later

from odoo import api, models


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

# This is a bit of a hack. Normally in hr_timesheet_overtime, the value of
# unit_amount is updated in this method as part of writing or creating a
# record. However, in hr_timesheet_activity_begin_end, unit_amount is
# adjusted during an onchange using unit_amount_from_start_stop.
#
# If BOTH the onchange and the write method adjust the value of unit_amount,
# then the rate is applied twice, which is not good. Therefore, this method
# is 'disabled', and we instead rely on onchange to correctly set the value
# of unit_amount.
#
# The disadvantage is that programmatic usages of hr_timesheet_overtime no
# longer work here. The advantage is that you can now manually override the
# value of unit_amount without the rate being automatically applied.
#
# In version 16, this behaviour is a lot less messy, because it uses compute
# functions instead of the aforementioned methods.
@api.model
def _update_values(self, values):
time_start = values.get("time_start", self.time_start)
time_stop = values.get("time_stop", self.time_stop)
# Do not double-compute if we're using times.
if time_start or time_stop:
return
return super()._update_values(values)

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 the two modules compatible.
Loading
Loading