forked from michel/Coworking
33 lines
954 B
Python
33 lines
954 B
Python
# -*- coding: utf-8 -*-
|
|
|
|
""" Coworker relation """
|
|
|
|
from odoo import models, fields, api, _
|
|
from odoo.exceptions import ValidationError
|
|
|
|
|
|
class CoworkerRelation(models.Model):
|
|
"""Coworker relation model """
|
|
_name = 'coworking.relation'
|
|
_description = 'relation model definition'
|
|
_order = 'id asc'
|
|
|
|
name = fields.Char()
|
|
|
|
coworker1 = fields.Many2one(
|
|
'res.partner', 'Coworker 1', index=True, required=True,
|
|
domain="[('is_coworker', '=', True)]"
|
|
)
|
|
coworker2 = fields.Many2one(
|
|
'res.partner', 'Coworker 2', index=True, required=True,
|
|
domain="[('is_coworker', '=', True)]"
|
|
)
|
|
relation = fields.Char(index=True, required=True)
|
|
|
|
|
|
@api.constrains('coworker1', 'coworker2')
|
|
def _check_if_coworker_is_same(self):
|
|
"""Test si coworker1 est identique à coworker2"""
|
|
if self.coworker1 == self.coworker2:
|
|
raise ValidationError(_('Coworker1 is same coworker2'))
|