From 641fe7f34f048caf179a1286ff0dfa733c17fcdf Mon Sep 17 00:00:00 2001 From: XavierDo Date: Thu, 23 Aug 2018 11:42:18 +0200 Subject: [PATCH] [FIX] calendar: only make leaf evaluation when necessary A little optimisation to avoid one more query when we have no recuring event, and only evaluate leaf of recuring event. --- addons/calendar/models/calendar.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/calendar/models/calendar.py b/addons/calendar/models/calendar.py index 800a519c2c1..44a442b0ad7 100644 --- a/addons/calendar/models/calendar.py +++ b/addons/calendar/models/calendar.py @@ -1110,10 +1110,11 @@ class Meeting(models.Model): order_fields.append('id') leaf_evaluations = None + recurrent_ids = [meeting.id for meeting in self if meeting.recurrency and meeting.rrule] #compose a query of the type SELECT id, condition1 as domain1, condition2 as domaine2 #This allows to load leaf interpretation of the where clause in one query #leaf_evaluations is then used when running custom interpretation of domain for recuring events - if self: + if self and recurrent_ids: select_fields = ["id"] where_params_list = [] for pos, arg in enumerate(domain): @@ -1124,7 +1125,7 @@ class Meeting(models.Model): where_params_list += where_params if len(select_fields) > 1: query = "SELECT %s FROM calendar_event WHERE id in %%s" % (", ".join(select_fields)) # could be improved by only taking event with recurency ? - where_params_list += [tuple(self.ids)] + where_params_list += [tuple(recurrent_ids)] self._cr.execute(query, where_params_list) leaf_evaluations = dict([(row['id'], row) for row in self._cr.dictfetchall()]) result_data = []