-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[REF] hr_timesheet_overtime: Add hours_worked field
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
- Loading branch information
1 parent
ab3ca34
commit ef2a7bb
Showing
10 changed files
with
219 additions
and
36 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
19 changes: 19 additions & 0 deletions
19
hr_timesheet_overtime/migrations/16.0.3.0.0/post-upgrade.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,19 @@ | ||
# SPDX-FileCopyrightText: 2024 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
|
||
def migrate(cr, version): | ||
# This is not strictly true, but it's the best way to populate the field | ||
# with sensible data. | ||
# | ||
# TODO: Does this run upon module installation? This needs to be run on | ||
# module installation as well. | ||
cr.execute( | ||
# Perfect symmetry is joyous | ||
""" | ||
UPDATE account_analytic_line | ||
SET hours_worked=unit_amount | ||
WHERE project_id IS NOT NULL | ||
""" | ||
) |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from . import account_analytic_line | ||
from . import hr_employee | ||
from . import hr_timesheet_sheet | ||
from . import hr_timesheet_sheet_line | ||
from . import resource_overtime | ||
from . import resource_overtime_rate |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# SPDX-FileCopyrightText: 2024 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class HrTimesheetSheetLineAbstract(models.AbstractModel): | ||
_inherit = "hr_timesheet.sheet.line.abstract" | ||
|
||
hours_worked = fields.Float(default=0.0) | ||
unit_amount = fields.Float( | ||
compute="_compute_unit_amount_from_hours", readonly=False | ||
) | ||
|
||
# TODO: this is basically identical to account.analytic.line. it's probably | ||
# fine? | ||
@api.depends("hours_worked", "date") | ||
def _compute_unit_amount_from_hours(self): | ||
for line in self: | ||
line.unit_amount = line.hours_worked * self.env[ | ||
"account.analytic.line" | ||
].rate_for_date(line.date) | ||
|
||
|
||
class HrTimesheetSheetLine(models.TransientModel): | ||
_inherit = "hr_timesheet.sheet.line" | ||
|
||
@api.onchange("unit_amount", "hours_worked") | ||
def onchange_unit_amount(self): | ||
return super().onchange_unit_amount() |
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 |
---|---|---|
|
@@ -8,10 +8,11 @@ | |
|
||
/* | ||
:Author: David Goodger ([email protected]) | ||
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ | ||
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ | ||
:Copyright: This stylesheet has been placed in the public domain. | ||
Default cascading style sheet for the HTML output of Docutils. | ||
Despite the name, some widely supported CSS2 features are used. | ||
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to | ||
customize this style sheet. | ||
|
@@ -274,7 +275,7 @@ | |
margin-left: 2em ; | ||
margin-right: 2em } | ||
|
||
pre.code .ln { color: grey; } /* line numbers */ | ||
pre.code .ln { color: gray; } /* line numbers */ | ||
pre.code, code { background-color: #eeeeee } | ||
pre.code .comment, code .comment { color: #5C6576 } | ||
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } | ||
|
@@ -300,7 +301,7 @@ | |
span.pre { | ||
white-space: pre } | ||
|
||
span.problematic { | ||
span.problematic, pre.problematic { | ||
color: red } | ||
|
||
span.section-subtitle { | ||
|
@@ -366,7 +367,7 @@ <h1 class="title">Timesheet/Contract - Overtime</h1> | |
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:f303e3ad17e5d88c4ddf2a1baf816f420994d594a04db998c4fd2c1e9f1b2131 | ||
!! source digest: sha256:bde6f189b3da65ae6a23a4337c16402e0a29f4ebbb8dd39431f53c37a66249ef | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> | ||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/coopiteasy/cie-timesheet/tree/16.0/hr_timesheet_overtime"><img alt="coopiteasy/cie-timesheet" src="https://img.shields.io/badge/github-coopiteasy%2Fcie--timesheet-lightgray.png?logo=github" /></a></p> | ||
<p>Computes overtime hours according to employee’s contracts.</p> | ||
|
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
89 changes: 89 additions & 0 deletions
89
hr_timesheet_overtime/views/account_analytic_line_views.xml
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,89 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
|
||
<record id="hr_timesheet_line_tree" model="ir.ui.view"> | ||
<field name="name">account.analytic.line.tree.hr_timesheet</field> | ||
<field name="model">account.analytic.line</field> | ||
<field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_tree" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//field[@name='unit_amount']" position="before"> | ||
<field | ||
name="hours_worked" | ||
widget="timesheet_uom" | ||
decoration-danger="hours_worked > 24 or hours_worked < 0" | ||
/> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
<record id="view_hr_timesheet_line_pivot" model="ir.ui.view"> | ||
<field name="name">account.analytic.line.pivot</field> | ||
<field name="model">account.analytic.line</field> | ||
<field name="inherit_id" ref="hr_timesheet.view_hr_timesheet_line_pivot" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//field[@name='unit_amount']" position="before"> | ||
<field name="hours_worked" type="measure" widget="timesheet_uom" /> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
<record id="view_hr_timesheet_line_graph" model="ir.ui.view"> | ||
<field name="name">account.analytic.line.graph</field> | ||
<field name="model">account.analytic.line</field> | ||
<field name="inherit_id" ref="hr_timesheet.view_hr_timesheet_line_graph" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//field[@name='unit_amount']" position="before"> | ||
<field name="hours_worked" type="measure" widget="timesheet_uom" /> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
<record id="view_hr_timesheet_line_graph_my" model="ir.ui.view"> | ||
<field name="name">account.analytic.line.graph</field> | ||
<field name="model">account.analytic.line</field> | ||
<field name="inherit_id" ref="hr_timesheet.view_hr_timesheet_line_graph_my" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//field[@name='unit_amount']" position="before"> | ||
<field name="hours_worked" type="measure" widget="timesheet_uom" /> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
<record id="view_hr_timesheet_line_graph_all" model="ir.ui.view"> | ||
<field name="name">account.analytic.line.graph</field> | ||
<field name="model">account.analytic.line</field> | ||
<field name="inherit_id" ref="hr_timesheet.view_hr_timesheet_line_graph_all" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//field[@name='unit_amount']" position="before"> | ||
<field name="hours_worked" type="measure" widget="timesheet_uom" /> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
<record id="hr_timesheet_line_form" model="ir.ui.view"> | ||
<field name="name">account.analytic.line.form</field> | ||
<field name="model">account.analytic.line</field> | ||
<field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//field[@name='unit_amount']" position="before"> | ||
<field | ||
name="hours_worked" | ||
widget="timesheet_uom" | ||
decoration-danger="hours_worked > 24" | ||
/> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
<record id="view_kanban_account_analytic_line" model="ir.ui.view"> | ||
<field name="name">account.analytic.line.kanban</field> | ||
<field name="model">account.analytic.line</field> | ||
<field name="inherit_id" ref="hr_timesheet.view_kanban_account_analytic_line" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//field[@name='unit_amount']" position="before"> | ||
<field name="hours_worked" widget="timesheet_uom" /> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
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