Commit 7bb16375 by Renaud Dufour

Do not allow changing the start or end *date* of a shift template because shift…

Do not allow changing the start or end *date* of a shift template because shift update won't work as expected. Changing times is still allowed.
parent 17c6354c
...@@ -409,6 +409,13 @@ msgid "Cancelled" ...@@ -409,6 +409,13 @@ msgid "Cancelled"
msgstr "Annulé" msgstr "Annulé"
#. module: coop_shift #. module: coop_shift
#: code:addons/coop_shift/model/shift_template.py:527
#: code:addons/coop_shift/model/shift_template.py:534
#, python-format
msgid "Cannot change the date of an existing shift template. Delete and create a new template instead."
msgstr "Il n'est pas possible de modifier la date d'un créneau existant. Vous pouvez modifier l'heure uniquement. Veuillez supprimer et créer un nouveau créneau pour modifier les dates."
#. module: coop_shift
#: model:ir.model.fields,field_description:coop_shift.field_shift_shift_event_type_id #: model:ir.model.fields,field_description:coop_shift.field_shift_shift_event_type_id
#: model:ir.model.fields,field_description:coop_shift.field_shift_shift_shift_type_id #: model:ir.model.fields,field_description:coop_shift.field_shift_shift_shift_type_id
#: model:ir.model.fields,field_description:coop_shift.field_shift_template_shift_type_id #: model:ir.model.fields,field_description:coop_shift.field_shift_template_shift_type_id
...@@ -1825,7 +1832,7 @@ msgstr "Participant(e)" ...@@ -1825,7 +1832,7 @@ msgstr "Participant(e)"
#: model:ir.ui.view,arch_db:coop_shift.view_shift_template_registration_line_search #: model:ir.ui.view,arch_db:coop_shift.view_shift_template_registration_line_search
#: model:ir.ui.view,arch_db:coop_shift.view_template_registration_search #: model:ir.ui.view,arch_db:coop_shift.view_template_registration_search
msgid "Partner" msgid "Partner"
msgstr "Coopérateur msgstr "Coopérateur"
#. module: coop_shift #. module: coop_shift
#: model:ir.model.fields,field_description:coop_shift.field_shift_template_registration_line_is_past #: model:ir.model.fields,field_description:coop_shift.field_shift_template_registration_line_is_past
......
...@@ -520,6 +520,20 @@ class ShiftTemplate(models.Model): ...@@ -520,6 +520,20 @@ class ShiftTemplate(models.Model):
if 'updated_fields' not in vals.keys() and len(self.shift_ids): if 'updated_fields' not in vals.keys() and len(self.shift_ids):
vals['updated_fields'] = str(vals) vals['updated_fields'] = str(vals)
if 'start_datetime' in vals and self.start_datetime is not None:
new_date = datetime.date(datetime.strptime(vals['start_datetime'], "%Y-%m-%d %H:%M:%S"))
current_date = datetime.date(datetime.strptime(self.start_datetime, "%Y-%m-%d %H:%M:%S"))
if new_date != current_date:
raise UserError(_(
"Cannot change the date of an existing shift template. Delete and create a new template instead."))
if 'end_datetime' in vals and self.end_datetime is not None:
new_date = datetime.date(datetime.strptime(vals['end_datetime'], "%Y-%m-%d %H:%M:%S"))
current_date = datetime.date(datetime.strptime(self.end_datetime, "%Y-%m-%d %H:%M:%S"))
if new_date != current_date:
raise UserError(_(
"Cannot change the date of an existing shift template. Delete and create a new template instead."))
if 'user_ids' in vals and 'updated_fields' in vals \ if 'user_ids' in vals and 'updated_fields' in vals \
and len(vals.keys()) <= 2: and len(vals.keys()) <= 2:
self.update_shift(vals) self.update_shift(vals)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment