Skip to content

Commit ca90fd1

Browse files
committed
[IMP] hr_payroll: add rate and extra hours functionality in work entry type
_* = hr_holidays, hr_work_entry, hr_work_entry_contract, hr_work_entry_holidays - The goal of this change is to improve the payroll system by providing a clearer and more flexible way to manage extra hours and overtime manually. - This update introduces the ability to mark specific work entry types as extra hours and define a custom rate to be applied during payslip computation. - HR managers can now manually configure both the extra hours flag and the associated rate on each work entry type. This PR includes: - Introduced a general rate field on work entry types to define the pay rate for any work entry. - Added a checkbox to mark specific work entry types as extra hours, so they are paid on top of the regular wage. - Updated the payslip logic to calculate the amount based on the defined rate for all work entry types. - Added a checkbox to the work entry type to determine if the amount should be added on top of the regular salary, based on the rate. - Updated the logic to handle all countries based on the new work entry type settings, allowing consistent rate application and extra work amount globally. (BE, HK, LU etc.) - Removed overtime rule parameters and country-specific hardcoded logic to make the extra hours and rate calculation more flexible across all countries. (PL, US, SK etc.) - Wrote upgrade scripts to handle old data and align it with new work entry type and rate logic across PL, SK, and US. - Removed old overtime rule parameters and updated work entries and worked days to match the new setup. Related Upgrade PR - odoo/upgrade#7364 Task - 4420535 closes odoo#206878 Related: odoo/enterprise#76506 Related: odoo/upgrade#7364 Signed-off-by: Yannick Tivisse (yti) <[email protected]>
1 parent 06eb664 commit ca90fd1

File tree

5 files changed

+55
-0
lines changed

5 files changed

+55
-0
lines changed

addons/hr_holidays/data/hr_leave_type_data.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,4 +573,16 @@
573573
<field name="company_id" eval="False"/>
574574
<field name="country_id" ref="base.sk"/>
575575
</record>
576+
577+
<!-- PL : Poland -->
578+
<record id="l10n_pl_leave_type_sick_leave" model="hr.leave.type">
579+
<field name="name">PL Sick Leaves 80% </field>
580+
<field name="requires_allocation">no</field>
581+
<field name="request_unit">half_day</field>
582+
<field name="support_document">True</field>
583+
<field name="icon_id" ref="hr_holidays.icon_21"/>
584+
<field name="color">6</field>
585+
<field name="company_id" eval="False"/>
586+
<field name="country_id" ref="base.pl"/>
587+
</record>
576588
</data></odoo>

addons/hr_work_entry/data/hr_work_entry_type_data.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,13 +809,24 @@
809809
<field name="is_leave" eval="True"/>
810810
</record>
811811

812+
<!-- PL : Poland -->
813+
<record id="l10n_pl_work_entry_type_sick_leave" model="hr.work.entry.type">
814+
<field name="name">Sick Time Off (Paid at 80%)</field>
815+
<field name="color">4</field>
816+
<field name="code">PLSICK3166</field>
817+
<field name="country_id" ref="base.pl"/>
818+
<field name="is_leave" eval="True"/>
819+
<field name="amount_rate">0.8</field>
820+
</record>
821+
812822
<!-- SK : Slovakia -->
813823
<record id="l10n_sk_work_entry_type_sick_25" model="hr.work.entry.type">
814824
<field name="name">Sick Time Off Day 1-3 (Paid at 25%)</field>
815825
<field name="code">SICK25</field>
816826
<field name="color">5</field>
817827
<field name="country_id" ref="base.sk"/>
818828
<field name="is_leave" eval="True"/>
829+
<field name="amount_rate">0.25</field>
819830
</record>
820831

821832
<record id="l10n_sk_work_entry_type_sick_55" model="hr.work.entry.type">
@@ -824,6 +835,7 @@
824835
<field name="color">5</field>
825836
<field name="country_id" ref="base.sk"/>
826837
<field name="is_leave" eval="True"/>
838+
<field name="amount_rate">0.55</field>
827839
</record>
828840

829841
<record id="l10n_sk_work_entry_type_sick_0" model="hr.work.entry.type">
@@ -832,6 +844,7 @@
832844
<field name="color">5</field>
833845
<field name="country_id" ref="base.sk"/>
834846
<field name="is_leave" eval="True"/>
847+
<field name="amount_rate">0.0</field>
835848
</record>
836849

837850
<record id="l10n_sk_work_entry_type_maternity" model="hr.work.entry.type">
@@ -840,6 +853,7 @@
840853
<field name="color">5</field>
841854
<field name="country_id" ref="base.sk"/>
842855
<field name="is_leave" eval="True"/>
856+
<field name="amount_rate">0.75</field>
843857
</record>
844858

845859
<record id="l10n_sk_work_entry_type_parental_time_off" model="hr.work.entry.type">
@@ -848,21 +862,32 @@
848862
<field name="color">8</field>
849863
<field name="country_id" ref="base.sk"/>
850864
<field name="is_leave" eval="True"/>
865+
<field name="amount_rate">0.0</field>
851866
</record>
852867

853868
<!-- US : United States -->
869+
<record id="l10n_us_work_entry_type_overtime" model="hr.work.entry.type">
870+
<field name="name">Overtime Hours (Paid at 150%)</field>
871+
<field name="color">4</field>
872+
<field name="code">USOVERTIME150</field>
873+
<field name="country_id" ref="base.us"/>
874+
<field name="amount_rate">1.5</field>
875+
</record>
876+
854877
<record id="l10n_us_work_entry_type_double" model="hr.work.entry.type">
855878
<field name="name">Double Time Hours</field>
856879
<field name="color">4</field>
857880
<field name="code">USDOUBLE</field>
858881
<field name="country_id" ref="base.us"/>
882+
<field name="amount_rate">2.0</field>
859883
</record>
860884

861885
<record id="l10n_us_work_entry_type_retro_overtime" model="hr.work.entry.type">
862886
<field name="name">Retro Overtime Hours</field>
863887
<field name="color">4</field>
864888
<field name="code">USRETROOVERTIME</field>
865889
<field name="country_id" ref="base.us"/>
890+
<field name="amount_rate">1.5</field>
866891
</record>
867892

868893
<record id="l10n_us_work_entry_type_retro_regular" model="hr.work.entry.type">
@@ -871,4 +896,5 @@
871896
<field name="code">USRETROREGULAR</field>
872897
<field name="country_id" ref="base.us"/>
873898
</record>
899+
874900
</data></odoo>

addons/hr_work_entry/models/hr_work_entry_type.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ class HrWorkEntryType(models.Model):
2727
is_work = fields.Boolean(
2828
compute='_compute_is_work', inverse='_inverse_is_work', string="Working Time", readonly=False,
2929
help="If checked, the work entry is counted as work time in the working schedule")
30+
amount_rate = fields.Float(
31+
string="Rate",
32+
default=1.0,
33+
help="If you want the hours should be paid double, the rate should be 200%.")
34+
is_extra_hours = fields.Boolean(
35+
string="Added to Monthly Pay",
36+
help="Check this setting if you want the hours to be considered as extra time and added as a bonus to the basic salary.")
3037

3138
@api.constrains('country_id')
3239
def _check_work_entry_type_country(self):

addons/hr_work_entry/views/hr_work_entry_views.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@
222222
</group>
223223
<group>
224224
<field name="country_id" options="{'no_create': True, 'no_open': True}"/>
225+
<label for="amount_rate"/>
226+
<div class="o_row mw-25" name="amount_rate">
227+
<field name="amount_rate" widget="percentage"/>
228+
</div>
229+
<field name="is_extra_hours"/>
225230
</group>
226231
</group>
227232
<group name="other">

addons/hr_work_entry_holidays/data/hr_leave_type_data.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,4 +211,9 @@
211211
<record id="hr_holidays.l10n_sk_leave_type_maternity" model="hr.leave.type">
212212
<field name="work_entry_type_id" ref="hr_work_entry.l10n_sk_work_entry_type_maternity"/>
213213
</record>
214+
215+
<!-- PL : Poland -->
216+
<record id="hr_holidays.l10n_pl_leave_type_sick_leave" model="hr.leave.type">
217+
<field name="work_entry_type_id" ref="hr_work_entry.l10n_pl_work_entry_type_sick_leave"/>
218+
</record>
214219
</odoo>

0 commit comments

Comments
 (0)