[IMP]Event model cleaning + search function handling of operator and value

This commit is contained in:
Fabien BOURGEOIS 2017-11-15 06:25:12 +01:00
parent 168f28d0c9
commit 663219440c

View File

@ -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):