forked from verdigado/odoo-customize
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] verdigado#57 allow higher value overtime for holidays
- Loading branch information
Showing
12 changed files
with
183 additions
and
2 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
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
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 @@ | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class HrEmployee(models.Model): | ||
_inherit = "hr.employee" | ||
|
||
holiday_overtime_factor = fields.Float( | ||
default=0, | ||
help="When activated on holidays/weekends, overtime is multiplied with this factor", | ||
) | ||
|
||
def _get_effective_holiday_overtime_factor(self, date=None): | ||
"""Return an employee's effective overtime factor for some date""" | ||
self.ensure_one() | ||
date = ( | ||
date | ||
or self.env["hr.attendance"]._get_day_start_and_day( | ||
self, | ||
fields.Datetime.now(), | ||
)[1] | ||
) | ||
return ( | ||
(self.holiday_overtime_factor or self.company_id.holiday_overtime_factor) | ||
if ( | ||
date.isoweekday() >= 6 | ||
or self.env["hr.holidays.public"].is_public_holiday(date, self.id) | ||
) | ||
else 1 | ||
) |
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,13 @@ | ||
# Copyright 2023 Hunki Enterprises BV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) | ||
|
||
|
||
from odoo import fields, models | ||
|
||
|
||
class ResConfigSettings(models.TransientModel): | ||
_inherit = "res.config.settings" | ||
|
||
holiday_overtime_factor = fields.Float( | ||
related="company_id.holiday_overtime_factor", readonly=False | ||
) |
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,11 @@ | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from odoo import api, models | ||
|
||
|
||
class ResUsers(models.Model): | ||
_inherit = "res.users" | ||
|
||
@api.model | ||
def get_effective_holiday_overtime_factor(self): | ||
return self.env.user.employee_id._get_effective_holiday_overtime_factor() |
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 @@ | ||
/* Copyright 2023 Hunki Enterprises BV | ||
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */ | ||
|
||
odoo.define("verdigado_attendance.hr_attendance", function (require) { | ||
"use strict"; | ||
|
||
var myAttendances = require("hr_attendance.my_attendances"); | ||
|
||
myAttendances.include({ | ||
events: _.extend({}, myAttendances.prototype.events, { | ||
"click .o_hr_attendance_break_icon": _.debounce( | ||
function () { | ||
this._hr_attendance_break(); | ||
}, | ||
200, | ||
true | ||
), | ||
}), | ||
|
||
willStart: function () { | ||
var self = this; | ||
var promise = this._rpc({ | ||
model: "res.users", | ||
method: "get_effective_holiday_overtime_factor", | ||
}).then(function (data) { | ||
self.effective_holiday_overtime_factor = data; | ||
}); | ||
return Promise.all([this._super.apply(this, arguments), promise]); | ||
}, | ||
}); | ||
}); |
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,15 @@ | ||
<?xml version="1.0" encoding="utf8" ?> | ||
<templates> | ||
<t t-inherit="hr_attendance.HrAttendanceMyMainMenu"> | ||
<xpath expr="//h4[@t-if='checked_in']" position="after"> | ||
<div t-if="checked_in and widget.effective_holiday_overtime_factor != 1"> | ||
<input type="checkbox" id="apply_holiday_overtime" checked="" /> | ||
<label for="apply_holiday_overtime"> | ||
Apply holiday overtime factor ( | ||
<t t-out="widget.effective_holiday_overtime_factor" /> | ||
) | ||
</label> | ||
</div> | ||
</xpath> | ||
</t> | ||
</templates> |
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,12 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<record id="view_employee_form" model="ir.ui.view"> | ||
<field name="inherit_id" ref="hr.view_employee_form" /> | ||
<field name="model">hr.employee</field> | ||
<field name="arch" type="xml"> | ||
<field name="pin" position="after"> | ||
<field name="holiday_overtime_factor" /> | ||
</field> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- Copyright 2023 Hunki Enterprises BV | ||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) --> | ||
<data> | ||
<record id="res_config_settings_view_form" model="ir.ui.view"> | ||
<field name="model">res.config.settings</field> | ||
<field name="inherit_id" ref="hr_attendance.res_config_settings_view_form" /> | ||
<field name="arch" type="xml"> | ||
<div name="overtime_settings" position="after"> | ||
<h2>Overtime on holidays</h2> | ||
<div class="row mt16 o_settings_container" name="break_settings"> | ||
<div class="col-12 col-lg-6 o_setting_box"> | ||
<div class="o_setting_left_pane" /> | ||
<div class="o_setting_right_pane"> | ||
<span | ||
class="fa fa-lg fa-building-o" | ||
title="Values set here are company-specific." | ||
role="img" | ||
aria-label="Values set here are company-specific." | ||
groups="base.group_multi_company" | ||
/> | ||
<label for="holiday_overtime_factor" /> | ||
<div class="text-muted"> | ||
When recording attendances on a holiday, this factor | ||
will be applied | ||
</div> | ||
<field name="holiday_overtime_factor" /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</field> | ||
</record> | ||
</data> |