From de1d04db4cac41268659db7637eb5ee403d80076 Mon Sep 17 00:00:00 2001 From: "Mahdi cheikh rouhou (macr)" Date: Mon, 3 Apr 2023 09:27:23 +0000 Subject: [PATCH] [FIX] calendar : change stop date for recurrent event Changing end time for recurrent event will generate an error. steps to reproduce the error: 1- Create an event in the calendar app with recurrence on 2- Save and close 3- Edit this event again and select change all events at the top 4- Change the ending time The error was happening because the wrong key was accessed in a dictionary opw-3236432 closes odoo/odoo#118087 X-original-commit: 97f51b24da5db1a0217121aae583a9c1d715adc4 Signed-off-by: Adrien Widart Signed-off-by: Mahdi Cheikh Rouhou (macr) --- addons/calendar/models/calendar_event.py | 2 +- addons/calendar/tests/test_event_recurrence.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/addons/calendar/models/calendar_event.py b/addons/calendar/models/calendar_event.py index 326f10c46da..b8efd071b61 100644 --- a/addons/calendar/models/calendar_event.py +++ b/addons/calendar/models/calendar_event.py @@ -994,7 +994,7 @@ class Meeting(models.Model): if not start_update: # Apply the same shift for start start = base_time_values['start'] + (stop_update - self.stop) - start_date = base_time_values['start_date'] + (stop_update.date() - self.stop.date()) + start_date = base_time_values['start'].date() + (stop_update.date() - self.stop.date()) update_dict.update({'start': start, 'start_date': start_date}) stop = base_time_values['stop'] + (stop_update - self.stop) stop_date = base_time_values['stop'].date() + (stop_update.date() - self.stop.date()) diff --git a/addons/calendar/tests/test_event_recurrence.py b/addons/calendar/tests/test_event_recurrence.py index d477e1b8359..8833ff661ea 100644 --- a/addons/calendar/tests/test_event_recurrence.py +++ b/addons/calendar/tests/test_event_recurrence.py @@ -403,6 +403,19 @@ class TestUpdateRecurrentEvents(TestRecurrentEvents): (datetime(2019, 11, 9, 1, 0), datetime(2019, 11, 12, 18, 0)), ]) + def test_shift_stop_all(self): + # testing the case where we only want to update the stop time + event = self.events[0] + event.write({ + 'recurrence_update': 'all_events', + 'stop': event.stop + relativedelta(hours=1), + }) + self.assertEventDates(event.recurrence_id.calendar_event_ids, [ + (datetime(2019, 10, 22, 2, 0), datetime(2019, 10, 24, 19, 0)), + (datetime(2019, 10, 29, 2, 0), datetime(2019, 10, 31, 19, 0)), + (datetime(2019, 11, 5, 2, 0), datetime(2019, 11, 7, 19, 0)), + ]) + def test_change_week_day_rrule(self): recurrence = self.events.recurrence_id recurrence.rrule = 'FREQ=WEEKLY;COUNT=3;BYDAY=WE' # from TU to WE