[FIX] calendar: Adjust meeting dates in an all_day setup
Steps to reproduce: - Calendar > create an all_day meeting with an additional attendee - Save > Edit > change starting date to a later day > traceback Cause of the issue: The write call of the method _onchange_date is applied to a pseudo record. However, the write method expects a record with an integer id to correctly _send_mail_to_attendees down the line. Fix: Since we don't want to send_mail_to_attendees anyway, we skip this part of the write method using the already existing contextual escape 'is_calendar_event_new'. opw-3733753 closes odoo/odoo#154091 X-original-commit: f206781b3f4cababa4e69c8c9586f0f5406acc83 Signed-off-by: Lancelot Semal (lase) <lase@odoo.com>
This commit is contained in:
@@ -373,7 +373,7 @@ class Meeting(models.Model):
|
||||
"""
|
||||
for event in self:
|
||||
if event.stop_date and event.start_date:
|
||||
event.write({
|
||||
event.with_context(is_calendar_event_new=True).write({
|
||||
'start': fields.Datetime.from_string(event.start_date).replace(hour=8),
|
||||
'stop': fields.Datetime.from_string(event.stop_date).replace(hour=18),
|
||||
})
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from odoo.tests.common import TransactionCase, new_test_user
|
||||
from odoo.tests.common import TransactionCase, new_test_user, Form
|
||||
from odoo import fields, Command
|
||||
|
||||
|
||||
class TestEventNotifications(TransactionCase):
|
||||
@@ -134,3 +136,24 @@ class TestEventNotifications(TransactionCase):
|
||||
})
|
||||
self.assertIn(self.partner, event.attendee_ids.partner_id, "Partner should be in attendee")
|
||||
self.assertNotIn(partner_bis, event.attendee_ids.partner_id, "Partner bis should not be in attendee")
|
||||
|
||||
def test_push_meeting_start(self):
|
||||
"""
|
||||
Checks that you can push the start date of an all day meeting.
|
||||
"""
|
||||
attendee = self.env['res.partner'].create({
|
||||
'name': "Xavier",
|
||||
'email': "xavier@example.com",
|
||||
})
|
||||
event = self.env['calendar.event'].create({
|
||||
'name': "Doom's day",
|
||||
'attendee_ids': [Command.create({'partner_id': attendee.id})],
|
||||
'allday': True,
|
||||
'start_date': fields.Date.today(),
|
||||
'stop_date': fields.Date.today(),
|
||||
})
|
||||
initial_start = event.start
|
||||
with Form(event) as event_form:
|
||||
event_form.stop_date = datetime.today() + relativedelta(days=1)
|
||||
event_form.start_date = datetime.today() + relativedelta(days=1)
|
||||
self.assertFalse(initial_start == event.start)
|
||||
|
||||
Reference in New Issue
Block a user