Coworking/coworking_relation/models/coworker.py

26 lines
883 B
Python
Raw Normal View History

2017-11-16 15:47:18 +01:00
# -*- 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')
2017-11-20 14:48:26 +01:00
#Relation fields
2017-11-20 15:07:59 +01:00
relation_ids = fields.One2many(
'coworking.relation', 'relation')
2017-11-16 15:47:18 +01:00
@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)