diff options
| author | Achraf (abz) <abz@odoo.com> | 2020-10-23 06:47:54 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2021-01-06 17:03:53 +0000 |
| commit | 79f27f640ccdd14f285a9dd9fc0ae770c992376f (patch) | |
| tree | ea7e5b3c37a800fc5f7053f4244b197c4cd74c35 /addons/crm | |
| parent | 5504ad189f66c63b930ae5a6f5838b8478ba28ec (diff) | |
[FIX] mail: send notification mail with right access link when using mail.thread
PURPOSE
Notification may be sent using a generic mail.thread record, notably when
sending user notifications. In that case links to view document are
incorrect.
HOW TO REPRODUCE
Issue
- Install "Approvals"
- Submit new approval with you as "Request Owner"
- Click on "View Approval Request" in your mailbox
The link redirects to a 505 error
Cause
The model is not the correct one and the res_id is undefined
Solution
Specify the model and the res_id to _notify_get_action_link
when creating the link with kwargs
SPECIFICATIONS
Propagate message value through various notification sub methods. That way
we can rely on them if model seems void.
Also limit values given as URL parameters to some white listed values.
LINKS
opw-2358846
Task ID-2379766
Followup of odoo/odoo#60998
Followup of odoo/odoo#61545
Closes odoo/odoo#63292
Closes odoo/enterprise#15585
closes odoo/odoo#64170
X-original-commit: 2b6d2b71f6c60bcf64db440473c88d1dc335acbf
Related: odoo/enterprise#15588
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Co-authored-by: Achraf Ben Azzouz <abz@odoo.com>
Co-authored-by: Thibault Delavallée <tde@odoo.com>
Diffstat (limited to 'addons/crm')
| -rw-r--r-- | addons/crm/models/crm_lead.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/addons/crm/models/crm_lead.py b/addons/crm/models/crm_lead.py index f92fd70807d..98cc8e26793 100644 --- a/addons/crm/models/crm_lead.py +++ b/addons/crm/models/crm_lead.py @@ -1336,24 +1336,29 @@ class Lead(models.Model): return self.env.ref('crm.mt_lead_lost') return super(Lead, self)._track_subtype(init_values) - def _notify_get_groups(self): + def _notify_get_groups(self, msg_vals=None): """ Handle salesman recipients that can convert leads into opportunities and set opportunities as won / lost. """ - groups = super(Lead, self)._notify_get_groups() + groups = super(Lead, self)._notify_get_groups(msg_vals=msg_vals) + msg_vals = msg_vals or {} self.ensure_one() if self.type == 'lead': - convert_action = self._notify_get_action_link('controller', controller='/lead/convert') + convert_action = self._notify_get_action_link('controller', controller='/lead/convert', **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') - lost_action = self._notify_get_action_link('controller', controller='/lead/case_mark_lost') + 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) salesman_actions = [ {'url': won_action, 'title': _('Won')}, {'url': lost_action, 'title': _('Lost')}] if self.team_id: - salesman_actions.append({'url': self._notify_get_action_link('view', res_id=self.team_id.id, model=self.team_id._name), 'title': _('Sales Team Settings')}) + custom_params = dict(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') + }) salesman_group_id = self.env.ref('sales_team.group_sale_salesman').id new_group = ( |
