From 663219440c047982c1a76bf00d2f635454b0371a Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Wed, 15 Nov 2017 06:25:12 +0100 Subject: [PATCH] [IMP]Event model cleaning + search function handling of operator and value --- models/event.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/models/event.py b/models/event.py index 07a3b51..e6ef7a6 100644 --- a/models/event.py +++ b/models/event.py @@ -24,13 +24,11 @@ class Event(models.Model): description = fields.Text() statut = fields.Selection([('draft', 'Draft'), ('confirmed', 'Confirmed'), - ('canceled', 'Canceled')], default='canceled') + ('canceled', 'Canceled')], default='draft') participants_ids = fields.Many2many('coworking.coworker', string='Subscribers') participants_count = fields.Integer('Number of participants', compute='_compute_participants_count') - participants_count2 = fields.Integer('Number of participants #2', - compute='_compute_participants_count') @api.depends('date_start') def _compute_starts_this_week(self): @@ -48,7 +46,11 @@ class Event(models.Model): week_start = date_start.isocalendar()[1] if datetime.now().isocalendar()[1] == week_start: res_ids.append(event.id) - return [('id', 'in', res_ids)] + if operator == '=': + operator = 'in'if value else 'not in' + else: + operator = 'not in'if value else 'in' + return [('id', operator, res_ids)] @api.depends('participants_ids') def _compute_participants_count(self):