From bc9bc2686ca142a7348dc48e0b7f8e74fdd42e10 Mon Sep 17 00:00:00 2001 From: Krupal Oza Date: Mon, 15 Mar 2021 14:13:22 +0000 Subject: [PATCH] [IMP] calendar: improve main data templates Purpose of this commit is to make templates easier to preview and edit as weel as to improve their content. This is achieved notably by lessening use of custom rendering context and trying to fix as much error-prone jinja statements. In this commit we also make ``calendar_template_meeting_reminder`` template looking more like other templates. There were some rendering differences that do not seem really wanted. ``calendar_template_meeting_reminder`` was also using an old ``force_event_id`` key not replaced by recurrent_id field on attendee. This commit improves few strings of the invitation mail being sent while booking an online appointment. Online appointment is computed based on ``appointment_type_id`` field being defined. Some tweaks in wording made it necessary to know if recipient is the responsible, customer or an added attendee on the event, leading to some tooling code added on event model. The main changes includes * for customer, remove the CTAs to accept / decline event as attendee are automatically set as accepted; * depending on recipient, improve wording of the mail accordingly and mention appointment type in the mail; Task ID-2199620 COM PR odoo/odoo#64925 ENT PR odoo/enterprise#15914 UPG PR odoo/upgrade#2282 Co-Authored-By: Krupal Oza Co-Authored-By: Thibault Delavallee --- addons/calendar/__manifest__.py | 2 +- addons/calendar/data/mail_template_data.xml | 143 +++++++++++++----- .../calendar/models/calendar_alarm_manager.py | 3 +- addons/calendar/models/calendar_attendee.py | 24 +-- addons/calendar/models/calendar_event.py | 81 ++++++++-- .../models/calendar_attendee.py | 4 +- .../models/calendar_attendee.py | 4 +- 7 files changed, 184 insertions(+), 77 deletions(-) diff --git a/addons/calendar/__manifest__.py b/addons/calendar/__manifest__.py index 106bc5c3869..2b1340d36e2 100644 --- a/addons/calendar/__manifest__.py +++ b/addons/calendar/__manifest__.py @@ -3,7 +3,7 @@ { 'name': 'Calendar', - 'version': '1.0', + 'version': '1.1', 'sequence': 165, 'depends': ['base', 'mail'], 'summary': "Schedule employees' meetings", diff --git a/addons/calendar/data/mail_template_data.xml b/addons/calendar/data/mail_template_data.xml index e411500fae8..4071428d26f 100644 --- a/addons/calendar/data/mail_template_data.xml +++ b/addons/calendar/data/mail_template_data.xml @@ -11,26 +11,46 @@ ${object.partner_id.lang}
- % set colors = ctx.get('colors', {}) - % set recurrent = object.recurrence_id and not ctx['ignore_recurrence'] + % set colors = {'needsAction': 'grey', 'accepted': 'green', 'tentative': '#FFFF00', 'declined': 'red'} + % set is_online = 'appointment_type_id' in object.event_id and object.event_id.appointment_type_id + % set customer = object.event_id.find_partner_customer() + % set target_responsible = object.partner_id == object.event_id.partner_id + % set target_customer = object.partner_id == customer

Hello ${object.common_name},

- ${object.event_id.user_id.partner_id.name} invited you to the ${object.event_id.name} meeting of ${object.event_id.user_id.company_id.name}. + + % if is_online and target_customer: + Your appointment ${object.event_id.appointment_type_id.name} with ${object.event_id.user_id.name} has been booked. + + % elif is_online and target_responsible: + % if customer + ${customer.name} scheduled the following appointment ${object.event_id.appointment_type_id.name} with you. + % else + Your appointment ${object.event_id.appointment_type_id.name} has been booked. + % endif + + % elif not target_responsible: + ${object.event_id.user_id.partner_id.name} invited you for the ${object.event_id.name} meeting. + + % else: + Your meeting ${object.event_id.name} has been booked. + % endif

- % set target = 'recurrence' if recurrent else 'meeting' - Accept - Decline + % endif - View + ${'Reschedule' if is_online and target_customer else 'View'} +
- % if not recurrent:
${object.event_id.get_interval('dayname', tz=object.partner_id.tz if not object.event_id.allday else None)} @@ -46,24 +66,35 @@
- % endif

Details of the event