[FW][FIX] mail, various: fix document access link computation

Purpose of this commit is to fix computation of access link. In some cases
msg_vals modification leads to invalid URL computation, notably for frontend
or backend differentiation for target recipients.

Followup of odoo/odoo#63292 .

Task ID-2513724
COM PR odoo/odoo#69607
ENT PR odoo/enterprise#17849

X-original-commit: e618597876692f2d24f8e9308c747b8d1f2d8905
This commit is contained in:
Thibault Delavallée
2021-04-23 15:24:58 +00:00
parent 31fcd5a0f1
commit effebe148f
5 changed files with 17 additions and 17 deletions
+5 -5
View File
@@ -1669,21 +1669,21 @@ class Lead(models.Model):
""" Handle salesman recipients that can convert leads into opportunities
and set opportunities as won / lost. """
groups = super(Lead, self)._notify_get_groups(msg_vals=msg_vals)
msg_vals = msg_vals or {}
local_msg_vals = dict(msg_vals or {})
self.ensure_one()
if self.type == 'lead':
convert_action = self._notify_get_action_link('controller', controller='/lead/convert', **msg_vals)
convert_action = self._notify_get_action_link('controller', controller='/lead/convert', **local_msg_vals)
salesman_actions = [{'url': convert_action, 'title': _('Convert to opportunity')}]
else:
won_action = self._notify_get_action_link('controller', controller='/lead/case_mark_won', **msg_vals)
lost_action = self._notify_get_action_link('controller', controller='/lead/case_mark_lost', **msg_vals)
won_action = self._notify_get_action_link('controller', controller='/lead/case_mark_won', **local_msg_vals)
lost_action = self._notify_get_action_link('controller', controller='/lead/case_mark_lost', **local_msg_vals)
salesman_actions = [
{'url': won_action, 'title': _('Won')},
{'url': lost_action, 'title': _('Lost')}]
if self.team_id:
custom_params = dict(msg_vals, res_id=self.team_id.id, model=self.team_id._name)
custom_params = dict(local_msg_vals, res_id=self.team_id.id, model=self.team_id._name)
salesman_actions.append({
'url': self._notify_get_action_link('view', **custom_params),
'title': _('Sales Team Settings')
+3 -3
View File
@@ -1221,15 +1221,15 @@ class HolidaysRequest(models.Model):
""" Handle HR users and officers recipients that can validate or refuse holidays
directly from email. """
groups = super(HolidaysRequest, self)._notify_get_groups(msg_vals=msg_vals)
msg_vals = msg_vals or {}
local_msg_vals = dict(msg_vals or {})
self.ensure_one()
hr_actions = []
if self.state == 'confirm':
app_action = self._notify_get_action_link('controller', controller='/leave/validate', **msg_vals)
app_action = self._notify_get_action_link('controller', controller='/leave/validate', **local_msg_vals)
hr_actions += [{'url': app_action, 'title': _('Approve')}]
if self.state in ['confirm', 'validate', 'validate1']:
ref_action = self._notify_get_action_link('controller', controller='/leave/refuse', **msg_vals)
ref_action = self._notify_get_action_link('controller', controller='/leave/refuse', **local_msg_vals)
hr_actions += [{'url': ref_action, 'title': _('Refuse')}]
holiday_user_group_id = self.env.ref('hr_holidays.group_hr_holidays_user').id
@@ -670,15 +670,15 @@ class HolidaysAllocation(models.Model):
""" Handle HR users and officers recipients that can validate or refuse holidays
directly from email. """
groups = super(HolidaysAllocation, self)._notify_get_groups(msg_vals=msg_vals)
msg_vals = msg_vals or {}
local_msg_vals = dict(msg_vals or {})
self.ensure_one()
hr_actions = []
if self.state == 'confirm':
app_action = self._notify_get_action_link('controller', controller='/allocation/validate', **msg_vals)
app_action = self._notify_get_action_link('controller', controller='/allocation/validate', **local_msg_vals)
hr_actions += [{'url': app_action, 'title': _('Approve')}]
if self.state in ['confirm', 'validate', 'validate1']:
ref_action = self._notify_get_action_link('controller', controller='/allocation/refuse', **msg_vals)
ref_action = self._notify_get_action_link('controller', controller='/allocation/refuse', **local_msg_vals)
hr_actions += [{'url': ref_action, 'title': _('Refuse')}]
holiday_user_group_id = self.env.ref('hr_holidays.group_hr_holidays_user').id
+4 -4
View File
@@ -63,13 +63,13 @@ class PortalMixin(models.AbstractModel):
def _notify_get_groups(self, msg_vals=None):
access_token = self._portal_ensure_token()
groups = super(PortalMixin, self)._notify_get_groups(msg_vals=msg_vals)
msg_vals = msg_vals or {}
local_msg_vals = dict(msg_vals or {})
if access_token and 'partner_id' in self._fields and self['partner_id']:
customer = self['partner_id']
msg_vals['access_token'] = self.access_token
msg_vals.update(customer.signup_get_auth_param()[customer.id])
access_link = self._notify_get_action_link('view', **msg_vals)
local_msg_vals['access_token'] = self.access_token
local_msg_vals.update(customer.signup_get_auth_param()[customer.id])
access_link = self._notify_get_action_link('view', **local_msg_vals)
new_group = [
('portal_customer', lambda pdata: pdata['id'] == customer.id, {
+2 -2
View File
@@ -1212,13 +1212,13 @@ class Task(models.Model):
access button to portal users and portal customers. If they are notified
they should probably have access to the document. """
groups = super(Task, self)._notify_get_groups(msg_vals=msg_vals)
msg_vals = msg_vals or {}
local_msg_vals = dict(msg_vals or {})
self.ensure_one()
project_user_group_id = self.env.ref('project.group_project_user').id
new_group = ('group_project_user', lambda pdata: pdata['type'] == 'user' and project_user_group_id in pdata['groups'], {})
if not self.user_id and not self.stage_id.fold:
take_action = self._notify_get_action_link('assign', **msg_vals)
take_action = self._notify_get_action_link('assign', **local_msg_vals)
project_actions = [{'url': take_action, 'title': _('I take it')}]
new_group[2]['actions'] = project_actions
groups = [new_group] + groups