diff --git a/models/coworker.py b/models/coworker.py
index 621caad..f06cc70 100644
--- a/models/coworker.py
+++ b/models/coworker.py
@@ -12,6 +12,7 @@ class Coworker(models.Model):
_order = 'id desc'
full_name = fields.Char(compute='_compute_full_name', store=True, index=True)
+
name = fields.Char(required=True)
firstname = fields.Char('First name', required=True)
coworker_type = fields.Selection([('staffer', 'Staffer'),
@@ -24,6 +25,7 @@ class Coworker(models.Model):
street = fields.Char()
contact_zip = fields.Char()
city = fields.Char()
+ full_contact_adress = fields.Char(compute='_compute_full_contact_adress')
phone_number = fields.Char()
gsm = fields.Char('GSM')
email = fields.Char()
@@ -33,19 +35,29 @@ class Coworker(models.Model):
is_done = fields.Boolean('Done?')
is_active = fields.Boolean('Active?', default=True)
+# Concaténation du nom et du prénom
@api.depends('name', 'firstname')
def _compute_full_name(self):
for coworker in self:
coworker.full_name = u'{} {}'.format(coworker.name, coworker.firstname)
-
+#Test sur contact_date pas de possibilitée de modification
+# la date est obligatoirement egale ou inferieur à la date enrengistré
@api.constrains('contact_date')
def _check_contact_date(self):
if self.contact_date > fields.Date.context_today(self):
- raise ValidationError(_('Date most be egual of inferior to to day'))
+ raise ValidationError(_('Date most be equal of inferior to to day'))
+#Contrainte python sur company_name et job, si il y a une raison sociale le champ job est à remplir
@api.constrains('company_name', 'job')
def _check_company_name(self):
for coworker in self:
if coworker.company_name and not coworker.job:
raise ValidationError(_('You must enter job and compagny both'))
+
+#Concatènation de l'adresse si les chanps street, contatc-zip et city sont renseignés
+ @api.depends('street', 'contact_zip', 'city')
+ def _compute_full_contact_adress(self):
+ for coworker in self:
+ if coworker.street and coworker.contact_zip and coworker.city:
+ coworker.full_contact_adress = u'{} {} {}'.format (coworker.street, coworker.contact_zip, coworker.city)
diff --git a/views/coworker_views.xml b/views/coworker_views.xml
index 561ec35..587bca2 100644
--- a/views/coworker_views.xml
+++ b/views/coworker_views.xml
@@ -23,6 +23,7 @@
+