Coworking/coworking_coworker/models/res_partner.py
2017-11-24 16:56:52 +01:00

33 lines
1010 B
Python

# -*- coding: utf-8 -*-
""" Coworker module """
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
class ResPartner(models.Model):
""" Coworker model """
_inherit = 'res.partner'
company_ids = fields.One2many(
string="Company",
comodel_name="res.partner",
inverse_name="parent_id",
)
contact_date = fields.Date(default=fields.Date.context_today)
coworker_type = fields.Selection([('staffer', 'Staffer'),
('worker', 'Worker'), ('member', 'Member'),
('volunteer', 'Volunteer'),
('visitor', 'Visitor')])
@api.constrains('contact_date')
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):
raise ValidationError(_('Date most be equal of inferior to to day'))