31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
""" Coworker adaptations """
|
|
|
|
from odoo import models, fields, api
|
|
|
|
class Coworker(models.Model):
|
|
""" Coworker adaptations """
|
|
_inherit = 'coworking.coworker'
|
|
|
|
manager_event_ids = fields.One2many('coworking.event', 'manager_id',
|
|
string='Events managed')
|
|
event_ids = fields.Many2many('coworking.event', string='Events visited')
|
|
|
|
events_coworker_count = fields.Integer('Number of event have participe',
|
|
compute='_compute_events_coworker_count')
|
|
#Relation fields
|
|
relation_ids = fields.One2many(
|
|
'coworking.relation', 'relation')
|
|
relation_ids = fields.One2many(
|
|
string="Relation",
|
|
comodel_name="coworking.relation",
|
|
inverse_name="relation",
|
|
)
|
|
|
|
@api.depends('event_ids')
|
|
def _compute_events_coworker_count(self):
|
|
""" Computes number of event coworker """
|
|
for event in self:
|
|
event.events_coworker_count = len(event.event_ids)
|