From 797bef0aee28ebef9f02ee8ab3ab2caac621304b Mon Sep 17 00:00:00 2001 From: michel Date: Wed, 15 Nov 2017 11:53:14 +0100 Subject: [PATCH] =?UTF-8?q?sur=20event=20:=20il=20faudrait=20que=20title?= =?UTF-8?q?=20soit=20reconnu=20comme=20le=20nom=20du=20mod=C3=A9le?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/event.py | 9 ++++++++- views/event_views.xml | 12 ++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/models/event.py b/models/event.py index e6ef7a6..44e362d 100644 --- a/models/event.py +++ b/models/event.py @@ -12,7 +12,7 @@ class Event(models.Model): _description = 'Event model definition' _order = 'id desc' - title = fields.Char(required=True) + name = fields.Char('Title', required=True) manager_id = fields.Many2one('coworking.coworker', 'Manager', index=True, domain="[('coworker_type', 'in', ['staffer', 'member'])]") date_start = fields.Datetime(default=fields.Date.context_today, required=True) @@ -30,6 +30,13 @@ class Event(models.Model): participants_count = fields.Integer('Number of participants', 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): """ Computes is event starts this week """ diff --git a/views/event_views.xml b/views/event_views.xml index 0509526..cf420a2 100644 --- a/views/event_views.xml +++ b/views/event_views.xml @@ -13,7 +13,7 @@ - + @@ -34,8 +34,8 @@ event Tree coworking.event - - + + @@ -50,7 +50,7 @@ coworking.event - + coworking.event - + display="name : [name]" > +