diff --git a/models/hr_timesheet.py b/models/hr_timesheet.py index 54ed9177807d1a24b7a678cea94495baee27ba3b..f9db0c7f4f97188579e562af857c1421ded732ae 100644 --- a/models/hr_timesheet.py +++ b/models/hr_timesheet.py @@ -72,6 +72,14 @@ class ScopHrTimesheet(models.Model): string="Lieu", ) justificatifs = fields.Char(string="Justificatifs", required=False) + is_overtime = fields.Boolean( + string="Heures supplémentaires", + default=False, + ) + is_overtime_allowed = fields.Boolean( + string="Heures supplémentaires autorisées", + compute="_compute_overtime_allowed", + ) calendar_l1 = fields.Char( string="Ligne 1 calendrier", @@ -85,6 +93,11 @@ class ScopHrTimesheet(models.Model): # ------------------------------------------------------ # Compute Functions # ------------------------------------------------------ + @api.depends("ur_id") + def _compute_overtime_allowed(self): + for rec in self: + rec.is_overtime_allowed = self.env.company.overtime_working + @api.depends("ur_id") def _compute_ur_system_nb(self): for timesheet in self: @@ -269,6 +282,10 @@ class ScopHrTimesheet(models.Model): if len(nbrc) == 0: custom_context['hide_regional_convention'] = True + overtime_allowed = self.env.company.overtime_working + if not overtime_allowed: + custom_context['hide_overtime'] = True + res = super(ScopHrTimesheet, self.with_context(custom_context)).fields_view_get( view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu) diff --git a/models/res_company.py b/models/res_company.py index 5bcb365f2be28c1c01532918747e4e0a1984c303..a32e41cdfde06b13d8c520e6e0613773165b18cb 100644 --- a/models/res_company.py +++ b/models/res_company.py @@ -18,3 +18,8 @@ class ResCompanyTmesheet(models.Model): help="Si cette option est cochée, un employé peut imputer sans limite" " de temps sur une journée", ) + overtime_working = fields.Boolean( + string="Heures supplémentaires", + default=False, + help="Si cette option est cochée, un employé peut déclarer des heures supplémentaire" + ) diff --git a/views/hr_timesheet.xml b/views/hr_timesheet.xml index f7c3d80bb7fa20d37f365c258487e0c9d7527fd9..1ddcc37b194a2f6d29ad9e77b0a671e96070ee1a 100644 --- a/views/hr_timesheet.xml +++ b/views/hr_timesheet.xml @@ -105,6 +105,12 @@ /> <field name="name" /> <field name="unit_amount" widget="float_time" /> + <field name="is_overtime_allowed" invisible="1" /> + <field + name="is_overtime" + widget="boolean_toggle" + attrs="{'invisible': [('is_overtime_allowed', '=', False)]}" + /> </group> <group string="Divers"> <field name="is_present" widget="boolean_toggle" /> @@ -179,6 +185,13 @@ /> <field name="name" /> <field name="unit_amount" widget="float_time" /> + <field name="is_overtime_allowed" invisible="1" /> + <field + name="is_overtime" + widget="boolean_toggle" + attrs="{'invisible': [('is_overtime_allowed', '=', False)]}" + /> + </group> <group string="Divers"> <field name="is_present" widget="boolean_toggle" /> @@ -267,6 +280,11 @@ >{'readonly': [('state', 'in', ('submit', 'valid'))]}</attribute> </field> <field name="unit_amount" position="after"> + <field + name="is_overtime" + widget="boolean_toggle" + invisible="context.get('hide_overtime')" + /> <field name="ur_regional_convention_nb" invisible="1" /> <field name="ur_financial_system_nb" invisible="1" /> <field diff --git a/views/res_company.xml b/views/res_company.xml index ae025e96d0426208245e815201423def449b1095..1a42e74e86242d0835957713c56696f4f23f2523 100644 --- a/views/res_company.xml +++ b/views/res_company.xml @@ -17,6 +17,7 @@ name="day_duration" attrs="{'invisible': [('day_working', '=', True)]}" /> + <field name="overtime_working" widget="boolean_toggle" /> </group> </group> </page>