Courtesy of Transifex's translators for reporting bad/unclear sentences. closes odoo/odoo#61804 X-original-commit: f5d0f4a1ebf406583889e9e04912d40c0693343e Related: odoo/enterprise#14769 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
22 lines
752 B
Python
22 lines
752 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import api, fields, models
|
|
|
|
|
|
class Contacts(models.Model):
|
|
_name = 'calendar.contacts'
|
|
_description = 'Calendar Contacts'
|
|
|
|
user_id = fields.Many2one('res.users', 'Me', required=True, default=lambda self: self.env.user)
|
|
partner_id = fields.Many2one('res.partner', 'Employee', required=True)
|
|
active = fields.Boolean('Active', default=True)
|
|
|
|
_sql_constraints = [
|
|
('user_id_partner_id_unique', 'UNIQUE(user_id, partner_id)', 'A user cannot have the same contact twice.')
|
|
]
|
|
|
|
@api.model
|
|
def unlink_from_partner_id(self, partner_id):
|
|
return self.search([('partner_id', '=', partner_id)]).unlink()
|