diff options
| author | Aurélien (avd) <avd@odoo.com> | 2021-03-03 16:43:43 +0000 |
|---|---|---|
| committer | Aurélien (avd) <avd@odoo.com> | 2021-04-16 08:25:41 +0000 |
| commit | 3e20e68f0790a0b0f3b5c4d43f59f235b7d20fef (patch) | |
| tree | 030b76926691eceeddfad129a0192fb731ed35e7 /addons/calendar | |
| parent | 02886f65e9026e1f7617c8b23c3d87edd358b168 (diff) | |
[FIX] calendar: improve calendar recurrency creation performances
Improve calendar recurrency creation performances by moving the call to
super().create out of the for loop. For a client database with 120
recurrences creating around 50k calendar events in total, the 5 times
averaged execution time went from 1410s to 630s, so a speed up slightly
bigger than 2.
Diffstat (limited to 'addons/calendar')
| -rw-r--r-- | addons/calendar/models/calendar_event.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/addons/calendar/models/calendar_event.py b/addons/calendar/models/calendar_event.py index 61ce4ef387d..558855c1abe 100644 --- a/addons/calendar/models/calendar_event.py +++ b/addons/calendar/models/calendar_event.py @@ -717,11 +717,12 @@ class Meeting(models.Model): events = super().create(other_vals) for vals in recurring_vals: + vals['follow_recurrence'] = True + recurring_events = super().create(recurring_vals) + events += recurring_events + for event, vals in zip(recurring_events, recurring_vals): recurrence_values = {field: vals.pop(field) for field in recurrence_fields if field in vals} - vals['follow_recurrence'] = True - event = super().create(vals) - events |= event if vals.get('recurrency'): detached_events = event._apply_recurrence_values(recurrence_values) detached_events.active = False |
