diff --git a/models/hr_timesheet.py b/models/hr_timesheet.py index f9db0c7f4f97188579e562af857c1421ded732ae..c15c513d4aed6858f481d6b0a6325f69edfcbc8f 100644 --- a/models/hr_timesheet.py +++ b/models/hr_timesheet.py @@ -80,7 +80,13 @@ class ScopHrTimesheet(models.Model): string="Heures supplémentaires autorisées", compute="_compute_overtime_allowed", ) - + travel_time = fields.Float( + string="Temps déplacement", + ) + is_travel_time_allowed = fields.Boolean( + string="Temps de déplacement autorisé", + compute="_compute_travel_time_allowed", + ) calendar_l1 = fields.Char( string="Ligne 1 calendrier", compute="_compute_calendar_l1", @@ -98,6 +104,11 @@ class ScopHrTimesheet(models.Model): for rec in self: rec.is_overtime_allowed = self.env.company.overtime_working + @api.depends("ur_id") + def _compute_travel_time_allowed(self): + for rec in self: + rec.is_travel_time_allowed = self.env.company.use_travel_time + @api.depends("ur_id") def _compute_ur_system_nb(self): for timesheet in self: @@ -285,6 +296,9 @@ class ScopHrTimesheet(models.Model): overtime_allowed = self.env.company.overtime_working if not overtime_allowed: custom_context['hide_overtime'] = True + travel_time_allowed = self.env.company.use_travel_time + if not travel_time_allowed: + custom_context['hide_travel_time'] = 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 a32e41cdfde06b13d8c520e6e0613773165b18cb..347bda9eb41e092b10e0ed081b74b1ae5d4db16a 100644 --- a/models/res_company.py +++ b/models/res_company.py @@ -23,3 +23,8 @@ class ResCompanyTmesheet(models.Model): default=False, help="Si cette option est cochée, un employé peut déclarer des heures supplémentaire" ) + use_travel_time = fields.Boolean( + string="Saisie des temps de déplacement", + default=False, + help="Si cette option est cochée, un employé peut saisir ses temps de déplacement" + ) diff --git a/views/hr_timesheet.xml b/views/hr_timesheet.xml index 1ddcc37b194a2f6d29ad9e77b0a671e96070ee1a..734b1b0faff2c217bd8d59e48bf92d9c6a08d954 100644 --- a/views/hr_timesheet.xml +++ b/views/hr_timesheet.xml @@ -106,6 +106,12 @@ <field name="name" /> <field name="unit_amount" widget="float_time" /> <field name="is_overtime_allowed" invisible="1" /> + <field name="is_travel_time_allowed" invisible="1" /> + <field + name="travel_time" + widget="float_time" + attrs="{'invisible': [('is_travel_time_allowed', '=', False)]}" + /> <field name="is_overtime" widget="boolean_toggle" @@ -186,6 +192,12 @@ <field name="name" /> <field name="unit_amount" widget="float_time" /> <field name="is_overtime_allowed" invisible="1" /> + <field name="is_travel_time_allowed" invisible="1" /> + <field + name="travel_time" + widget="float_time" + attrs="{'invisible': [('is_travel_time_allowed', '=', False)]}" + /> <field name="is_overtime" widget="boolean_toggle" @@ -280,6 +292,11 @@ >{'readonly': [('state', 'in', ('submit', 'valid'))]}</attribute> </field> <field name="unit_amount" position="after"> + <field + name="travel_time" + widget="float_time" + invisible="context.get('hide_travel_time')" + /> <field name="is_overtime" widget="boolean_toggle" diff --git a/views/res_company.xml b/views/res_company.xml index 1a42e74e86242d0835957713c56696f4f23f2523..8c31bd9332dd50dbd011dcd79d7b5e2e1647287e 100644 --- a/views/res_company.xml +++ b/views/res_company.xml @@ -18,6 +18,7 @@ attrs="{'invisible': [('day_working', '=', True)]}" /> <field name="overtime_working" widget="boolean_toggle" /> + <field name="use_travel_time" widget="boolean_toggle" /> </group> </group> </page>