diff --git a/addons/hr_work_entry_holidays/tests/test_performance.py b/addons/hr_work_entry_holidays/tests/test_performance.py index 746a1a8f283..7272d7730a6 100644 --- a/addons/hr_work_entry_holidays/tests/test_performance.py +++ b/addons/hr_work_entry_holidays/tests/test_performance.py @@ -32,7 +32,7 @@ class TestWorkEntryHolidaysPerformance(TestWorkEntryHolidaysBase): self.richard_emp.generate_work_entries(date(2018, 1, 1), date(2018, 1, 2)) leave = self.create_leave(datetime(2018, 1, 1, 7, 0), datetime(2018, 1, 1, 18, 0)) - with self.assertQueryCount(__system__=92, admin=96): + with self.assertQueryCount(__system__=94, admin=98): leave.action_validate() leave.action_refuse() diff --git a/addons/mail/__manifest__.py b/addons/mail/__manifest__.py index a9b70d82eb1..57014d155b9 100644 --- a/addons/mail/__manifest__.py +++ b/addons/mail/__manifest__.py @@ -101,6 +101,7 @@ For more specific needs, you may also assign custom-defined actions 'views/mail_gateway_allowed_views.xml', 'views/mail_guest_views.xml', 'views/mail_message_reaction_views.xml', + 'views/mail_templates_public.xml', 'views/res_users_views.xml', 'views/res_users_settings_views.xml', 'views/mail_template_views.xml', diff --git a/addons/mail/controllers/mail.py b/addons/mail/controllers/mail.py index 62fcc30019e..a3abb1213ac 100644 --- a/addons/mail/controllers/mail.py +++ b/addons/mail/controllers/mail.py @@ -4,7 +4,7 @@ import logging from werkzeug.urls import url_encode -from odoo import http +from odoo import _, http from odoo.exceptions import AccessError from odoo.http import request from odoo.tools import consteq @@ -164,3 +164,28 @@ class MailController(http.Controller): except ValueError: res_id = False return self._redirect_to_record(model, res_id, access_token, **kwargs) + + # csrf is disabled here because it will be called by the MUA with unpredictable session at that time + @http.route('/mail/unfollow', type='http', auth='public', csrf=False) + def mail_action_unfollow(self, model, res_id, pid, token, **kwargs): + comparison, record, __ = MailController._check_token_and_record_or_redirect(model, int(res_id), token) + if not comparison or not record: + raise AccessError(_('Non existing record or wrong token.')) + + pid = int(pid) + record_sudo = record.sudo() + record_sudo.message_unsubscribe([pid]) + + display_link = True + if request.session.uid: + try: + record.check_access_rights('read') + record.check_access_rule('read') + except AccessError: + display_link = False + + return request.render('mail.message_document_unfollowed', { + 'name': record_sudo.display_name, + 'model_name': request.env['ir.model'].sudo()._get(model).display_name, + 'access_url': record._notify_get_action_link('view', model=model, res_id=res_id) if display_link else False, + }) diff --git a/addons/mail/controllers/mailbox.py b/addons/mail/controllers/mailbox.py index a5f335449a9..26397082de6 100644 --- a/addons/mail/controllers/mailbox.py +++ b/addons/mail/controllers/mailbox.py @@ -7,8 +7,11 @@ from odoo.http import request class MailboxController(http.Controller): @http.route("/mail/inbox/messages", methods=["POST"], type="json", auth="user") def discuss_inbox_messages(self, before=None, after=None, limit=30, around=None): + partner_id = request.env.user.partner_id.id domain = [("needaction", "=", True)] - return request.env["mail.message"]._message_fetch(domain, before, after, around, limit).message_format() + return (request.env["mail.message"] + ._message_fetch(domain, before, after, around, limit) + ._message_format_personalize(partner_id)) @http.route("/mail/history/messages", methods=["POST"], type="json", auth="user") def discuss_history_messages(self, before=None, after=None, limit=30): diff --git a/addons/mail/data/mail_templates_email_layouts.xml b/addons/mail/data/mail_templates_email_layouts.xml index 91c06bccd2e..b631713e0bb 100644 --- a/addons/mail/data/mail_templates_email_layouts.xml +++ b/addons/mail/data/mail_templates_email_layouts.xml @@ -100,9 +100,12 @@
-+