Skip to content

Commit 633ef9f

Browse files
[FIX] mail, crm, hr_holidays: fix redirection for custom mail routes
Like fixed in previous commits, we now correctly fallback on web, my or login depending on user type. It is going to generate a valid /mail/view route when token is wrong for some reason instead of randomly redirecting everyone to Inbox. Task-4685166 X-original-commit: odoo/odoo@4209c17 Part-of: odoo#213889 Signed-off-by: Thibault Delavallee (tde) <[email protected]>
1 parent 8482edc commit 633ef9f

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

addons/crm/controllers/main.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from odoo.addons.mail.controllers.mail import MailController
66
from odoo import http
7-
from odoo.http import request
87

98
_logger = logging.getLogger(__name__)
109

@@ -19,7 +18,7 @@ def crm_lead_case_mark_won(self, res_id, token):
1918
record.action_set_won_rainbowman()
2019
except Exception:
2120
_logger.exception("Could not mark crm.lead as won")
22-
return MailController._redirect_to_messaging()
21+
return MailController._redirect_to_generic_fallback('crm.lead', res_id)
2322
return redirect
2423

2524
@http.route('/lead/case_mark_lost', type='http', auth='user', methods=['GET'])
@@ -30,7 +29,7 @@ def crm_lead_case_mark_lost(self, res_id, token):
3029
record.action_set_lost()
3130
except Exception:
3231
_logger.exception("Could not mark crm.lead as lost")
33-
return MailController._redirect_to_messaging()
32+
return MailController._redirect_to_generic_fallback('crm.lead', res_id)
3433
return redirect
3534

3635
@http.route('/lead/convert', type='http', auth='user', methods=['GET'])
@@ -41,5 +40,5 @@ def crm_lead_convert(self, res_id, token):
4140
record.convert_opportunity(record.partner_id)
4241
except Exception:
4342
_logger.exception("Could not convert crm.lead to opportunity")
44-
return MailController._redirect_to_messaging()
43+
return MailController._redirect_to_generic_fallback('crm.lead', res_id)
4544
return redirect

addons/hr_holidays/controllers/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def hr_holidays_request_validate(self, res_id, token):
2424
try:
2525
record.action_validate()
2626
except Exception:
27-
return MailController._redirect_to_messaging()
27+
return MailController._redirect_to_generic_fallback('hr.leave', res_id)
2828
return redirect
2929

3030
@http.route('/leave/refuse', type='http', auth='user', methods=['GET'])
@@ -34,7 +34,7 @@ def hr_holidays_request_refuse(self, res_id, token):
3434
try:
3535
record.action_refuse()
3636
except Exception:
37-
return MailController._redirect_to_messaging()
37+
return MailController._redirect_to_generic_fallback('hr.leave', res_id)
3838
return redirect
3939

4040
@http.route('/allocation/validate', type='http', auth='user', methods=['GET'])
@@ -44,7 +44,7 @@ def hr_holidays_allocation_validate(self, res_id, token):
4444
try:
4545
record.action_approve()
4646
except Exception:
47-
return MailController._redirect_to_messaging()
47+
return MailController._redirect_to_generic_fallback('hr.leave.allocation', res_id)
4848
return redirect
4949

5050
@http.route('/allocation/refuse', type='http', auth='user', methods=['GET'])
@@ -54,5 +54,5 @@ def hr_holidays_allocation_refuse(self, res_id, token):
5454
try:
5555
record.action_refuse()
5656
except Exception:
57-
return MailController._redirect_to_messaging()
57+
return MailController._redirect_to_generic_fallback('hr.leave.allocation', res_id)
5858
return redirect

addons/mail/controllers/mail.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ def _check_token_and_record_or_redirect(cls, model, res_id, token):
5959
comparison = cls._check_token(token)
6060
if not comparison:
6161
_logger.warning('Invalid token in route %s', request.httprequest.url)
62-
return comparison, None, cls._redirect_to_messaging()
62+
return comparison, None, cls._redirect_to_generic_fallback(model, res_id)
6363
try:
6464
record = request.env[model].browse(res_id).exists()
6565
except Exception:
6666
record = None
67-
redirect = cls._redirect_to_messaging()
67+
redirect = cls._redirect_to_generic_fallback(model, res_id)
6868
else:
6969
redirect = cls._redirect_to_record(model, res_id)
7070
return comparison, record, redirect

0 commit comments

Comments
 (0)