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_form_coop
1 résultat
Sélectionner une révision Git
  • 12.0
  • 13.0
  • 14.0
3 résultats
Afficher les modifications
Validations sur la source (2)
......@@ -104,13 +104,17 @@ class CgscopFormCoopDemande(models.Model):
formation_desc = fields.Text(
string="Description de la formation",
)
formation_date = fields.Date(
string="Date de la formation",
string="Date formation (1er jour)",
default=fields.Date.today(),
index=True,
tracking=1,
)
formation_date_end = fields.Date(
string="Date formation (dernier jour)",
index=True,
tracking=1,
)
formation_nb_jours = fields.Integer(
string="Nombre de jours de formation",
)
......@@ -216,6 +220,22 @@ class CgscopFormCoopDemande(models.Model):
)
)
@api.constrains("formation_date", "formation_date_end")
def _check_formation_date(self):
"""
Montant accpted <= montant formation
"""
for rec in self:
if rec.formation_date and \
rec.formation_date_end and \
rec.formation_date > rec.formation_date_end:
raise exceptions.ValidationError(
_(
"La date de fin de formation doit être supérieure ou égale"
" à la date de début de formation"
)
)
# adresse mail valide
@api.constrains("contact_mail")
def _check_contact_mail(self):
......
......@@ -81,11 +81,16 @@ class CgscopFormCoopDemandeCollective(models.Model):
string="Description de la formation",
)
formation_date = fields.Date(
string="Date de la formation",
string="Date formation (1er jour)",
default=fields.Date.today(),
index=True,
tracking=1,
)
formation_date_end = fields.Date(
string="Date formation (dernier jour)",
index=True,
tracking=1,
)
formation_nb_jours = fields.Integer(
string="Nombre de jours de formation",
)
......@@ -160,6 +165,25 @@ class CgscopFormCoopDemandeCollective(models.Model):
motif_refus = fields.Text(string="Motif du refus", tracking=1)
commentaires = fields.Text(string="Commentaires", tracking=1)
# ------------------------------------------------------
# Constrains
# ------------------------------------------------------
@api.constrains("formation_date", "formation_date_end")
def _check_formation_date(self):
"""
Montant accpted <= montant formation
"""
for rec in self:
if rec.formation_date and \
rec.formation_date_end and \
rec.formation_date > rec.formation_date_end:
raise exceptions.ValidationError(
_(
"La date de fin de formation doit être supérieure ou égale"
" à la date de début de formation"
)
)
# ------------------------------------------------------
# Computed fields
# ------------------------------------------------------
......
......@@ -168,6 +168,10 @@
required="1"
attrs="{'readonly': [('etat', 'not in', ('created'))]}"
/>
<field
name="formation_date_end"
attrs="{'readonly': [('etat', 'not in', ('created'))]}"
/>
<field
name="formation_id"
options="{'no_open': True, 'no_create': True}"
......
......@@ -213,6 +213,10 @@
required="1"
attrs="{'readonly': ['|',('demande_type', 'not in', ('I')),('etat', 'not in', ('created'))]}"
/>
<field
name="formation_date_end"
attrs="{'readonly': ['|',('demande_type', 'not in', ('I')),('etat', 'not in', ('created'))]}"
/>
<field
name="formation_id"
options="{'no_open': True, 'no_create': True}"
......