This commit is contained in:
michel 2017-11-06 15:54:17 +01:00
parent 5c4c8ca532
commit fc1274ef62
2 changed files with 12 additions and 5 deletions

View File

@ -2,7 +2,8 @@
""" Coworker module """
from odoo import models, fields
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
class Coworker(models.Model):
""" Coworker model """
@ -18,9 +19,9 @@ class Coworker(models.Model):
('visitor', 'Visitor')])
company_name = fields.Char('Company')
job = fields.Char()
contact_date = fields.Date()
contact_date = fields.Date(default=fields.Date.context_today)
street = fields.Char()
postal_code = fields.Char()
contact_zip = fields.Char()
city = fields.Char()
phone_number = fields.Char()
gsm = fields.Char('GSM')
@ -30,3 +31,9 @@ class Coworker(models.Model):
is_done = fields.Boolean('Done?')
is_active = fields.Boolean('Active?', default=True)
@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'))

View File

@ -20,7 +20,7 @@
</group>
<group name="group_right">
<field name="street" />
<field name="postal_code" />
<field name="contact_zip" />
<field name="city" />
<field name="gsm" />
<field name="phone_number" />
@ -72,7 +72,7 @@
<separator />
<filter name="is_savoyar" string="Is_savoyar"
domain="[('postal_code','=like','73___')]" />
domain="[('contact_zip','=like','73___')]" />
<filter name="meet_of_2017" string="Meet_of_2017"
domain="[('contact_date','like','2017')]" />