From fb4c7c0af22f4fff8da997b9732abe716f6f1946 Mon Sep 17 00:00:00 2001
From: "CGSCOP\\hsilvant" <hsilvant@scop.coop>
Date: Wed, 29 Jan 2025 20:28:43 +0100
Subject: [PATCH] =?UTF-8?q?Ajout=20d'un=20temps=20de=20d=C3=A9placement=20?=
=?UTF-8?q?sur=20la=20ligne=20de=20temps?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
models/hr_timesheet.py | 16 +++++++++++++++-
models/res_company.py | 5 +++++
views/hr_timesheet.xml | 17 +++++++++++++++++
views/res_company.xml | 1 +
4 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/models/hr_timesheet.py b/models/hr_timesheet.py
index f9db0c7..c15c513 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 a32e41c..347bda9 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 1ddcc37..734b1b0 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 1a42e74..8c31bd9 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>
--
GitLab