Skip to content
Extraits de code Groupes Projets

Comparer les révisions

Les modifications sont affichées comme si la révision source était fusionnée avec la révision cible. En savoir plus sur la comparaison des révisions.

Source

Sélectionner le projet cible
No results found
Sélectionner une révision Git
  • 12.0
  • 13.0
  • 14.0
3 résultats

Cible

Sélectionner le projet cible
  • lefilament/cgscop/cgscop_timesheet
  • hsilvant/cgscop_timesheet
2 résultats
Sélectionner une révision Git
  • 12-RV-Orthographe
  • 12.0
  • 14-RV-20250129
  • 14-RV-20250305
  • 14-RV-20250312
5 résultats
Afficher les modifications
Validations sur la source (12)
......@@ -72,7 +72,21 @@ 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",
)
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",
......@@ -85,6 +99,16 @@ 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_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:
......@@ -190,6 +214,10 @@ class ScopHrTimesheet(models.Model):
@api.constrains("date")
def _check_weekday(self):
if self.env.company.weekend_working:
return
for line in self:
dt = datetime.combine(line.date, time(12, 00))
holiday = self.env["resource.calendar.leaves"].search(
......@@ -199,9 +227,10 @@ class ScopHrTimesheet(models.Model):
("company_id", "=", self.env.company.id),
("date_from", "<=", dt),
("date_to", ">=", dt),
("resource_id", "=", False),
]
)
if line.date.weekday() in (5, 6) or holiday:
if not line.holiday_id and (line.date.weekday() in (5, 6) or holiday):
raise ValidationError(
_(
"Vous ne pouvez imputer du temps sur un weekend "
......@@ -252,3 +281,30 @@ class ScopHrTimesheet(models.Model):
"default_name": self[0].name if len(self) == 1 else "",
},
}
# ------------------------------------------------------
# Modification du context pour cacher les colonnes
# ------------------------------------------------------
@api.model
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
custom_context = self.env.context.copy()
current_ur_id = self.env.context['current_ur_id']
nbfs = self.env["ur.financial.system"].search([("ur_id", "=", current_ur_id)])
if len(nbfs) == 0:
custom_context['hide_financial_system'] = True
nbrc = self.env["ur.regional.convention"].search([("ur_id", "=", current_ur_id)])
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
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)
return res
......@@ -21,6 +21,9 @@ class ScopProjectTimesheet(models.Model):
ondelete="restrict",
default=_default_ur,
)
creation_invoiced = fields.Boolean(
string="Facturé au titre de la création",
)
@api.onchange("name")
def onchange_name(self):
......
......@@ -18,3 +18,18 @@ 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"
)
weekend_working = fields.Boolean(
string="Travail le weekend",
default=False,
help="Si cette option est cochée, un employé peut imputer le weekend",
)
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"
)
......@@ -105,6 +105,18 @@
/>
<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"
attrs="{'invisible': [('is_overtime_allowed', '=', False)]}"
/>
</group>
<group string="Divers">
<field name="is_present" widget="boolean_toggle" />
......@@ -179,6 +191,19 @@
/>
<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"
attrs="{'invisible': [('is_overtime_allowed', '=', False)]}"
/>
</group>
<group string="Divers">
<field name="is_present" widget="boolean_toggle" />
......@@ -267,17 +292,29 @@
>{'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"
invisible="context.get('hide_overtime')"
/>
<field name="ur_regional_convention_nb" invisible="1" />
<field name="ur_financial_system_nb" invisible="1" />
<field
name="ur_financial_system_id"
options="{'no_open': True, 'no_create': True}"
attrs="{'required': [('ur_financial_system_nb', '>', 0)], 'invisible': [('ur_financial_system_nb', '&lt;', 1)], 'readonly': [('state', 'in', ('submit', 'valid'))]}"
invisible="context.get('hide_financial_system')"
attrs="{'required': [('ur_financial_system_nb', '>', 0)], 'readonly': [('state', 'in', ('submit', 'valid'))]}"
/>
<field
name="ur_regional_convention_id"
options="{'no_open': True, 'no_create': True}"
attrs="{'required':[('ur_regional_convention_nb', '>', 0)], 'invisible':[('ur_regional_convention_nb', '&lt;', 1)], 'readonly': [('state', 'in', ('submit', 'valid'))]}"
invisible="context.get('hide_regional_convention')"
attrs="{'required':[('ur_regional_convention_nb', '>', 0)], 'readonly': [('state', 'in', ('submit', 'valid'))]}"
/>
<field
name="justificatifs"
......
......@@ -68,6 +68,7 @@
placeholder="Code activité National"
options="{'no_open': True, 'no_create': True}"
/>
<field name="creation_invoiced" widget="boolean_toggle" />
<field name="analytic_account_id" invisible="1" />
<field name="privacy_visibility" invisible="1" />
<field name="allow_timesheets" invisible="1" />
......
......@@ -17,6 +17,9 @@
name="day_duration"
attrs="{'invisible': [('day_working', '=', True)]}"
/>
<field name="overtime_working" widget="boolean_toggle" />
<field name="weekend_working" widget="boolean_toggle" />
<field name="use_travel_time" widget="boolean_toggle" />
</group>
</group>
</page>
......