From 033fc508f4b6330cb1a8d25cfd75c103c648edbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 16 Sep 2016 11:13:04 +0200 Subject: [PATCH] [FIX] mail: fix notification buttons url generation * Assign controller now effectively redirects to mail/assign instead of mail/assign * Follow and Unfollow button now uses the helper that generated the link --- addons/mail/controllers/main.py | 2 +- addons/mail/models/mail_thread.py | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/addons/mail/controllers/main.py b/addons/mail/controllers/main.py index c579226a617..adfa7edbfe3 100644 --- a/addons/mail/controllers/main.py +++ b/addons/mail/controllers/main.py @@ -193,7 +193,7 @@ class MailController(http.Controller): return werkzeug.utils.redirect('/mail/view?%s' % url_encode({'model': model, 'res_id': res_id})) @http.route('/mail/assign', type='http', auth='user') - def mail_action_assign(self, model, res_id, **kwargs): + def mail_action_assign(self, model, res_id): if model not in request.env: return self._redirect_to_messaging() Model = request.env[model] diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index d75011b92d7..aa7e70cc8df 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -562,16 +562,15 @@ class MailThread(models.AbstractModel): 'message_id': kwargs.pop('message_id') } else: - self.ensure_one() base_params = { - 'model': self._name, - 'res_id': self.ids[0], + 'model': kwargs.pop('model', self._name), + 'res_id': kwargs.pop('res_id', self.ids and self.ids[0] or False), } link = False if link_type in ['view', 'assign', 'follow', 'unfollow']: params = dict(base_params) - link = '/mail/view?%s' % url_encode(params) + link = '/mail/%s?%s' % (link_type, url_encode(params)) elif link_type == 'workflow': params = dict(base_params, signal=kwargs['signal']) link = '/mail/workflow?%s' % url_encode(params) @@ -655,8 +654,8 @@ class MailThread(models.AbstractModel): 'followers': self.env['res.partner'], 'not_followers': self.env['res.partner'], 'button_access': {'url': access_link, 'title': view_title}, - 'button_follow': {'url': '/mail/follow?%s' % url_encode({'model': message.model, 'res_id': message.res_id}), 'title': _('Follow')}, - 'button_unfollow': {'url': '/mail/unfollow?%s' % url_encode({'model': message.model, 'res_id': message.res_id}), 'title': _('Unfollow')}, + 'button_follow': {'url': self._notification_link_helper('follow', model=message.model, res_id=message.res_id), 'title': _('Follow')}, + 'button_unfollow': {'url': self._notification_link_helper('unfollow', model=message.model, res_id=message.res_id), 'title': _('Unfollow')}, 'actions': list(), } group_data[category] = self.env['res.partner']