michel_coworking/models/coworker.py

40 lines
1.3 KiB
Python
Raw Permalink Normal View History

# -*- coding: utf-8 -*-
""" Coworker module """
2017-11-06 15:54:17 +01:00
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
class Coworker(models.Model):
""" Coworker model """
_name = 'coworking.coworker'
_description = 'Coworker model definition'
_order = 'id desc'
name = fields.Char(required=True)
firstname = fields.Char('First name', required=True)
coworker_type = fields.Selection([('staffer', 'Staffer'),
('worker', 'Worker'), ('member', 'Member'),
('volunteer', 'Volunteer'),
('visitor', 'Visitor')])
company_name = fields.Char('Company')
job = fields.Char()
2017-11-06 15:54:17 +01:00
contact_date = fields.Date(default=fields.Date.context_today)
street = fields.Char()
2017-11-06 15:54:17 +01:00
contact_zip = fields.Char()
city = fields.Char()
phone_number = fields.Char()
gsm = fields.Char('GSM')
email = fields.Char()
url = fields.Char('URL')
note = fields.Text()
is_done = fields.Boolean('Done?')
is_active = fields.Boolean('Active?', default=True)
2017-11-06 15:54:17 +01:00
@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'))