From ffd1399e67350bc3bf9a724b7b922c796c573d37 Mon Sep 17 00:00:00 2001 From: michel Date: Wed, 15 Nov 2017 12:31:47 +0100 Subject: [PATCH] =?UTF-8?q?Sp=C3=A9cifications=20v2:=20Il=20nous=20manque?= =?UTF-8?q?=20le=20nombre=20d'=C3=A9v=C3=A9nements=20auquel=20le=20coworke?= =?UTF-8?q?r=20a=20particip=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/coworker.py | 10 ++++++++++ models/event.py | 5 ----- views/coworker_views.xml | 1 + 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/models/coworker.py b/models/coworker.py index 3c3006f..87e0b63 100644 --- a/models/coworker.py +++ b/models/coworker.py @@ -47,6 +47,16 @@ class Coworker(models.Model): 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') + + + @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) + @api.depends('name', 'firstname') def _compute_full_name(self): diff --git a/models/event.py b/models/event.py index 7e76fea..b5a68f5 100644 --- a/models/event.py +++ b/models/event.py @@ -31,11 +31,6 @@ class Event(models.Model): compute='_compute_participants_count') - @api.depends('participants_ids') - def _compute_participants_count(self): - """ Computes number of participants """ - for event in self: - event.participants_count = len(event.participants_ids) @api.depends('date_start') def _compute_starts_this_week(self): diff --git a/views/coworker_views.xml b/views/coworker_views.xml index 7c5cbff..91ff0bd 100644 --- a/views/coworker_views.xml +++ b/views/coworker_views.xml @@ -42,6 +42,7 @@ +