_compute_coworker_relation_ids
This commit is contained in:
parent
78ff3e754f
commit
16758eec6d
@ -2,7 +2,9 @@
|
||||
|
||||
""" Coworker adaptations """
|
||||
|
||||
import logging
|
||||
from odoo import models, fields, api
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class Coworker(models.Model):
|
||||
""" Coworker adaptations """
|
||||
@ -16,19 +18,23 @@ class Coworker(models.Model):
|
||||
compute='_compute_events_coworker_count')
|
||||
#Relation fields
|
||||
|
||||
coworker1_relation_ids = fields.One2many(
|
||||
string="Relation",
|
||||
coworker_relation_ids = fields.One2many(
|
||||
string="Relations",
|
||||
comodel_name="coworking.relation",
|
||||
inverse_name="coworker1"
|
||||
)
|
||||
coworker2_relation_ids = fields.One2many(
|
||||
string="Relation with you",
|
||||
comodel_name="coworking.relation",
|
||||
inverse_name="coworker2"
|
||||
)
|
||||
|
||||
inverse_name="coworker2",
|
||||
compute="_compute_coworker_relation_ids")
|
||||
|
||||
|
||||
@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)
|
||||
|
||||
def _compute_coworker_relation_ids(self):
|
||||
""" Computes coworker1_relation_ids and coworker2_relation_ids """
|
||||
for coworker in self:
|
||||
relation_model = self.env['coworking.relation']
|
||||
domain = ('|', ['coworker1', '=', coworker.id],
|
||||
['coworker2', '=', coworker.id])
|
||||
coworker.coworker_relation_ids = relation_model.search(domain)
|
||||
|
@ -11,8 +11,7 @@
|
||||
<notebook position="inside">
|
||||
<page string="Relation" name="Relation">
|
||||
<group name="relation">
|
||||
<field name="coworker1_relation_ids" context="{'default_coworker1': active_id}" />
|
||||
<field name="coworker2_relation_ids" context="{'default_coworker2': active_id}" />
|
||||
<field name="coworker_relation_ids" />
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
|
Loading…
Reference in New Issue
Block a user