compute_full_contact_adress clean version
This commit is contained in:
parent
561aa7a49d
commit
1c2175b51b
@ -35,35 +35,30 @@ class Coworker(models.Model):
|
|||||||
is_done = fields.Boolean('Done?')
|
is_done = fields.Boolean('Done?')
|
||||||
is_active = fields.Boolean('Active?', default=True)
|
is_active = fields.Boolean('Active?', default=True)
|
||||||
|
|
||||||
# Concaténation du nom et du prénom
|
|
||||||
@api.depends('name', 'firstname')
|
@api.depends('name', 'firstname')
|
||||||
def _compute_full_name(self):
|
def _compute_full_name(self):
|
||||||
|
"""Concaténation du nom et du prénom"""
|
||||||
for coworker in self:
|
for coworker in self:
|
||||||
coworker.full_name = u'{} {}'.format(coworker.name, coworker.firstname)
|
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')
|
@api.constrains('contact_date')
|
||||||
def _check_contact_date(self):
|
def _check_contact_date(self):
|
||||||
|
"""Test si la modification de la date n'est pas superieur à la date du jour"""
|
||||||
if self.contact_date > fields.Date.context_today(self):
|
if self.contact_date > fields.Date.context_today(self):
|
||||||
raise ValidationError(_('Date most be equal 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')
|
@api.constrains('company_name', 'job')
|
||||||
def _check_company_name(self):
|
def _check_company_name(self):
|
||||||
for coworker in self:
|
for coworker in self:
|
||||||
|
"""Contrainte python sur company_name et job,
|
||||||
|
si il y a une raison sociale le champ job est à remplir
|
||||||
|
"""
|
||||||
if coworker.company_name and not coworker.job:
|
if coworker.company_name and not coworker.job:
|
||||||
raise ValidationError(_('You must enter job and compagny both'))
|
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')
|
@api.depends('street', 'contact_zip', 'city')
|
||||||
def _compute_full_contact_adress(self):
|
def _compute_full_contact_adress(self):
|
||||||
|
"""Concatènation de l'adresse si les chanps street, contact-zip et city sont renseignés"""
|
||||||
for coworker in self:
|
for coworker in self:
|
||||||
if coworker.city:
|
coworker.full_contact_adress = u'{} {} {}'.format \
|
||||||
coworker.full_contact_adress = u'{}'.format(coworker.city)
|
(coworker.street or u'', coworker.contact_zip or u'', coworker.city or u'').strip()
|
||||||
|
|
||||||
if coworker.contact_zip and coworker.city:
|
|
||||||
coworker.full_contact_adress = u'{} {}'.format(coworker.contact_zip, coworker.city)
|
|
||||||
|
|
||||||
if coworker.street and coworker.contact_zip and coworker.city:
|
|
||||||
coworker.full_contact_adress = u'{} {} {}'.format(coworker.street, coworker.contact_zip, coworker.city)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user