-
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.
Merge pull request #81 from hbrunn/15.0-57-holiday_overtime_factor
[ADD] #57 allow higher value overtime for holidays
- Loading branch information
Showing
15 changed files
with
334 additions
and
51 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
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,54 @@ | ||
# 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" | ||
|
||
custom_holiday_overtime_factor = fields.Boolean( | ||
help="Use a custom overtime factor for holidays/weekens instead of the company's", | ||
groups="hr.group_hr_user", | ||
) | ||
holiday_overtime_factor = fields.Float( | ||
default=0, | ||
help="When activated on holidays/weekends, overtime is multiplied with this factor", | ||
groups="hr.group_hr_user", | ||
) | ||
|
||
def _get_effective_holiday_overtime_factor(self, date=None): | ||
"""Return an employee's effective overtime factor for some date""" | ||
self.ensure_one() | ||
self = self.sudo() | ||
date = ( | ||
date | ||
or self.env["hr.attendance"]._get_day_start_and_day( | ||
self, | ||
fields.Datetime.now(), | ||
)[1] | ||
) | ||
return ( | ||
( | ||
self.custom_holiday_overtime_factor | ||
and 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 | ||
) | ||
|
||
def _attendance_action_change(self): | ||
"""React to default flag for overtime factor""" | ||
result = super()._attendance_action_change() | ||
if "default_apply_holiday_overtime_factor" in self.env.context: | ||
result.write( | ||
{ | ||
"apply_holiday_overtime_factor": self.env.context[ | ||
"default_apply_holiday_overtime_factor" | ||
], | ||
} | ||
) | ||
return result |
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,33 @@ | ||
/* 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({ | ||
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]); | ||
}, | ||
_rpc: function (params) { | ||
if ( | ||
params && | ||
params.model === "hr.employee" && | ||
params.method === "attendance_manual" | ||
) { | ||
params.context.default_apply_holiday_overtime_factor = this.$( | ||
"#apply_holiday_overtime" | ||
).is(":checked"); | ||
} | ||
return this._super.apply(this, arguments); | ||
}, | ||
}); | ||
}); |
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,16 @@ | ||
<?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 | ||
<!-- prettier-ignore-start --> | ||
(<t t-out="widget.effective_holiday_overtime_factor" />) | ||
<!-- prettier-ignore-end --> | ||
</label> | ||
</div> | ||
</xpath> | ||
</t> | ||
</templates> |
Oops, something went wrong.