summaryrefslogtreecommitdiff
path: root/addons/hr_holidays
diff options
context:
space:
mode:
authorAchraf (abz) <abz@odoo.com>2020-10-23 06:47:54 +0000
committerThibault Delavallée <tde@odoo.com>2021-01-06 17:03:53 +0000
commit79f27f640ccdd14f285a9dd9fc0ae770c992376f (patch)
treeea7e5b3c37a800fc5f7053f4244b197c4cd74c35 /addons/hr_holidays
parent5504ad189f66c63b930ae5a6f5838b8478ba28ec (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/hr_holidays')
-rw-r--r--addons/hr_holidays/models/hr_leave.py9
-rw-r--r--addons/hr_holidays/models/hr_leave_allocation.py9
2 files changed, 10 insertions, 8 deletions
diff --git a/addons/hr_holidays/models/hr_leave.py b/addons/hr_holidays/models/hr_leave.py
index 99374e23944..a8d22fe3c94 100644
--- a/addons/hr_holidays/models/hr_leave.py
+++ b/addons/hr_holidays/models/hr_leave.py
@@ -1209,18 +1209,19 @@ class HolidaysRequest(models.Model):
return leave_notif_subtype or self.env.ref('hr_holidays.mt_leave')
return super(HolidaysRequest, self)._track_subtype(init_values)
- def _notify_get_groups(self):
+ def _notify_get_groups(self, msg_vals=None):
""" Handle HR users and officers recipients that can validate or refuse holidays
directly from email. """
- groups = super(HolidaysRequest, self)._notify_get_groups()
+ groups = super(HolidaysRequest, self)._notify_get_groups(msg_vals=msg_vals)
+ msg_vals = msg_vals or {}
self.ensure_one()
hr_actions = []
if self.state == 'confirm':
- app_action = self._notify_get_action_link('controller', controller='/leave/validate')
+ app_action = self._notify_get_action_link('controller', controller='/leave/validate', **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')
+ ref_action = self._notify_get_action_link('controller', controller='/leave/refuse', **msg_vals)
hr_actions += [{'url': ref_action, 'title': _('Refuse')}]
holiday_user_group_id = self.env.ref('hr_holidays.group_hr_holidays_user').id
diff --git a/addons/hr_holidays/models/hr_leave_allocation.py b/addons/hr_holidays/models/hr_leave_allocation.py
index f0b65351fcc..b93514953b9 100644
--- a/addons/hr_holidays/models/hr_leave_allocation.py
+++ b/addons/hr_holidays/models/hr_leave_allocation.py
@@ -666,18 +666,19 @@ class HolidaysAllocation(models.Model):
return allocation_notif_subtype_id or self.env.ref('hr_holidays.mt_leave_allocation')
return super(HolidaysAllocation, self)._track_subtype(init_values)
- def _notify_get_groups(self):
+ def _notify_get_groups(self, msg_vals=None):
""" Handle HR users and officers recipients that can validate or refuse holidays
directly from email. """
- groups = super(HolidaysAllocation, self)._notify_get_groups()
+ groups = super(HolidaysAllocation, self)._notify_get_groups(msg_vals=msg_vals)
+ msg_vals = msg_vals or {}
self.ensure_one()
hr_actions = []
if self.state == 'confirm':
- app_action = self._notify_get_action_link('controller', controller='/allocation/validate')
+ app_action = self._notify_get_action_link('controller', controller='/allocation/validate', **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')
+ ref_action = self._notify_get_action_link('controller', controller='/allocation/refuse', **msg_vals)
hr_actions += [{'url': ref_action, 'title': _('Refuse')}]
holiday_user_group_id = self.env.ref('hr_holidays.group_hr_holidays_user').id