[IMP] website_{event_meet, jitsi}: set default value for 'Max Capacity'
Before this commit: When user tries to create an event meeting room without selecting 'Max Capacity', it throws a Validation Error because 'Max Capacity' is a required field. After this commit: We provide the default value for 'Max Capicity' field on event meeting room to avoid default ORM Validation Error while saving the record. Note: Because the 'Max Capacity' is a selection field, displayed with radio widget, we can't make it required from the view unlike other fields. Also, in the 'chat.room.mixin', when we create a chat room on the fly from create method, instead of popping the ROOM_CONFIG_FIELDS, we propagate them (same like in write method), so that the room being created respects value selected by user (instead of taking the default one if we pop it). Task-id : 2448435 closes odoo/odoo#72756 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
@@ -24,6 +24,7 @@ class EventMeetingRoom(models.Model):
|
||||
event_id = fields.Many2one("event.event", string="Event", required=True, ondelete="cascade")
|
||||
is_pinned = fields.Boolean("Is Pinned")
|
||||
chat_room_id = fields.Many2one("chat.room", required=True, ondelete="restrict")
|
||||
room_max_capacity = fields.Selection(default="8", copy=True)
|
||||
summary = fields.Char("Summary", translate=True)
|
||||
target_audience = fields.Char("Audience", translate=True)
|
||||
|
||||
|
||||
@@ -25,10 +25,11 @@ class TestWebsiteEventMeet(TestEventCommon):
|
||||
"event_id": self.event_0.id,
|
||||
"target_audience": "dev"
|
||||
})
|
||||
|
||||
self.assertTrue(meeting_room.chat_room_id)
|
||||
self.assertTrue(meeting_room.chat_room_id.name)
|
||||
self.assertEqual(meeting_room.chat_room_id.max_capacity, "8")
|
||||
# Ensure default value for room_max_capacity in event.meeting.room
|
||||
self.assertEqual(meeting_room.room_max_capacity, "8")
|
||||
|
||||
def test_meeting_room_copy(self):
|
||||
"""Test the duplication of the meeting room."""
|
||||
@@ -54,6 +55,10 @@ class TestWebsiteEventMeet(TestEventCommon):
|
||||
|
||||
meeting_room_3 = meeting_room_1.copy()
|
||||
self.assertEqual(meeting_room_3.room_name, 'odoo-room-test-meeting-room-2')
|
||||
# Ensure room_max_capacity is copied to new meeting room
|
||||
self.assertEqual(meeting_room_3.room_max_capacity, "20")
|
||||
# Ensure max_capacity in linked chat room is same
|
||||
self.assertEqual(meeting_room_3.chat_room_id.max_capacity, "20")
|
||||
|
||||
def test_meeting_room_unlink(self):
|
||||
"""Test the duplication of the meeting room."""
|
||||
|
||||
@@ -38,7 +38,7 @@ class ChatRoomMixin(models.AbstractModel):
|
||||
if any(values.get(fmatch[0]) for fmatch in self.ROOM_CONFIG_FIELDS) and not values.get('chat_room_id'):
|
||||
if values.get('room_name'):
|
||||
values['room_name'] = self._jitsi_sanitize_name(values['room_name'])
|
||||
room_values = dict((fmatch[1], values.pop(fmatch[0])) for fmatch in self.ROOM_CONFIG_FIELDS if values.get(fmatch[0]))
|
||||
room_values = dict((fmatch[1], values[fmatch[0]]) for fmatch in self.ROOM_CONFIG_FIELDS if values.get(fmatch[0]))
|
||||
values['chat_room_id'] = self.env['chat.room'].create(room_values).id
|
||||
return super(ChatRoomMixin, self).create(values_list)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user