From 61e9b6ac4ecd653434c3ece62bea2f7563ef9be1 Mon Sep 17 00:00:00 2001 From: Kevin Baptiste Date: Wed, 9 Dec 2020 08:19:04 +0100 Subject: [PATCH] [IMP] calendar: add link to join video call This commit adds a link to each calendar.event to join a video call hosted on Jitsi. The domain of the Jitsi instance can be configured using the configuration parameter `website_jitsi.jitsi_server_domain` (defaults to meet.jit.si). TaskID: 2367543 --- addons/calendar/data/mail_template_data.xml | 9 +++++++++ addons/calendar/models/calendar_event.py | 12 ++++++++++++ addons/calendar/static/src/scss/calendar.scss | 9 +++++++++ addons/calendar/views/calendar_views.xml | 6 ++++++ addons/hr_holidays/models/hr_leave.py | 1 + 5 files changed, 37 insertions(+) diff --git a/addons/calendar/data/mail_template_data.xml b/addons/calendar/data/mail_template_data.xml index 64b89533668..e411500fae8 100644 --- a/addons/calendar/data/mail_template_data.xml +++ b/addons/calendar/data/mail_template_data.xml @@ -77,6 +77,9 @@ % endfor + % if object.event_id.videocall_location: +
  • Join Video Call: ${object.event_id.videocall_location}
  • + % endif @@ -168,6 +171,9 @@ % endfor + % if object.event_id.videocall_location: +
  • Join Video Call: ${object.event_id.videocall_location}
  • + % endif @@ -257,6 +263,9 @@ % endfor + % if object.event_id.videocall_location: +
  • Join Video Call: ${object.event_id.videocall_location}
  • + % endif diff --git a/addons/calendar/models/calendar_event.py b/addons/calendar/models/calendar_event.py index 86aa3c89fef..3ed48e65847 100644 --- a/addons/calendar/models/calendar_event.py +++ b/addons/calendar/models/calendar_event.py @@ -3,9 +3,11 @@ from datetime import timedelta import math +from uuid import uuid4 import babel.dates import logging import pytz +from werkzeug.urls import url_join from odoo import api, fields, models from odoo import tools @@ -78,6 +80,15 @@ class Meeting(models.Model): partners |= self.env['res.partner'].browse(active_id) return partners + @api.model + def _default_videocall_location(self): + if self.env.context.get('calendar_no_videocall'): + return False + jitsi_url = self.env['ir.config_parameter'].sudo().get_param('website_jitsi.jitsi_server_domain', 'meet.jit.si') + if not jitsi_url.startswith('http'): + jitsi_url = 'https://' + jitsi_url + return url_join(jitsi_url, 'odoo-%s' % (uuid4().hex[:12])) + def _find_my_attendee(self): """ Return the first attendee where the user connected has been invited from all the meeting_ids in parameters. @@ -211,6 +222,7 @@ class Meeting(models.Model): ('confidential', 'Only internal users')], 'Privacy', default='public', required=True) location = fields.Char('Location', tracking=True, help="Location of Event") + videocall_location = fields.Char('Join Video Call', default=_default_videocall_location) show_as = fields.Selection( [('free', 'Available'), ('busy', 'Busy')], 'Show Time as', default='busy', required=True) diff --git a/addons/calendar/static/src/scss/calendar.scss b/addons/calendar/static/src/scss/calendar.scss index 4260c9bad73..63cb48353aa 100644 --- a/addons/calendar/static/src/scss/calendar.scss +++ b/addons/calendar/static/src/scss/calendar.scss @@ -68,3 +68,12 @@ font-weight: bold; } } + +.o_cw_body .o_field_copy { + max-width: calc(100% - 6rem); + width: unset !important; +} + +.o_cw_body .o_clipboard_button { + padding-top: 0px !important; +} diff --git a/addons/calendar/views/calendar_views.xml b/addons/calendar/views/calendar_views.xml index 24006e897d5..bd9a559cc3a 100644 --- a/addons/calendar/views/calendar_views.xml +++ b/addons/calendar/views/calendar_views.xml @@ -112,6 +112,11 @@ class="oe_inline"/> + + + + + @@ -255,6 +260,7 @@ event_open_popup="true" event_limit="5" color="user_id"> + diff --git a/addons/hr_holidays/models/hr_leave.py b/addons/hr_holidays/models/hr_leave.py index 7163941fd50..1b82c77662d 100644 --- a/addons/hr_holidays/models/hr_leave.py +++ b/addons/hr_holidays/models/hr_leave.py @@ -869,6 +869,7 @@ class HolidaysRequest(models.Model): meeting_values = meeting_holidays._prepare_holidays_meeting_values() meetings = self.env['calendar.event'].with_context( no_mail_to_attendees=True, + calendar_no_videocall=True, active_model=self._name ).create(meeting_values) for holiday, meeting in zip(meeting_holidays, meetings):