[FIX] calendar: set correct recurring start_date
A recurring event with a start date and a time duration had a wrong start and
stop date computed.
Introduced at 76b724294a.
Previously the r_date contained only the start_date but now it contains both
start and stop dates. This implies that the method 'get_recurrent_ids' could
use 'get_search_fields' with a stop_date (depending on the domain order) and
returns incorrect dates.
This commit ensure to launch the get_search_fields with the start date.
Closes #15922
This commit is contained in:
@@ -1054,7 +1054,7 @@ class Meeting(models.Model):
|
||||
|
||||
if [True for item in new_pile if not item]:
|
||||
continue
|
||||
result_data.append(meeting.get_search_fields(order_fields, r_date=r_date))
|
||||
result_data.append(meeting.get_search_fields(order_fields, r_date=r_start_date))
|
||||
|
||||
if order_fields:
|
||||
uniq = lambda it: collections.OrderedDict((id(x), x) for x in it).values()
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo.tests import common
|
||||
from odoo.addons.calendar.models.calendar import calendar_id2real_id
|
||||
|
||||
|
||||
class TestRecurrentEvent(common.TransactionCase):
|
||||
@@ -145,3 +146,26 @@ class TestRecurrentEvent(common.TransactionCase):
|
||||
('start', '>=', '2017-06-30 08:00:00'), ('name', '=', 'Review code with programmer')
|
||||
])
|
||||
self.assertEqual(meetings_count, 1, "Last recurrent weekly meetings are not found without stop filter !")
|
||||
|
||||
def test_recurrent_meeting5(self):
|
||||
# I create a recurrent event and I check if the virtual_id are correct
|
||||
self.CalendarEvent.create({
|
||||
'count': 5,
|
||||
'start': '2012-04-13 11:00:00',
|
||||
'stop': '2012-04-13 12:00:00',
|
||||
'duration': 1.0,
|
||||
'name': 'Test Meeting',
|
||||
'recurrency': True,
|
||||
'rrule_type': 'daily'
|
||||
})
|
||||
# I search for the first recurrent meeting
|
||||
meeting = self.CalendarEvent.with_context({'virtual_id': True}).search([
|
||||
('start', '=', '2012-04-13 11:00:00'), ('stop', '=', '2012-04-13 12:00:00')
|
||||
])
|
||||
virutal_dates = calendar_id2real_id(meeting.id, with_date=True)
|
||||
|
||||
# virtual_dates are used by the calendar view and I check if the start date for the first virtual event is correct.
|
||||
self.assertEqual(virutal_dates[1], '2012-04-13 11:00:00', "The virtual event doesn't have the correct start date !")
|
||||
|
||||
# virtual_dates are used by the calendar view and I check if the stop date for the first virtual event is correct.
|
||||
self.assertEqual(virutal_dates[2], '2012-04-13 12:00:00', "The virtual event doesn't have the correct stop date !")
|
||||
|
||||
Reference in New Issue
Block a user