summaryrefslogtreecommitdiff
path: root/addons/link_tracker/controller/main.py
diff options
context:
space:
mode:
authorThibault Delavallée <tde@odoo.com>2018-10-29 14:23:16 +0000
committerThibault Delavallée <tde@odoo.com>2019-01-14 10:34:26 +0000
commitb670911a92883ebea49d427acafe2abac2753ace (patch)
tree72c4e143401d10882813702b85b6261718b36ec0 /addons/link_tracker/controller/main.py
parent75638ffb94fa4ae1753f733d8cb6f7f58f0b6a0a (diff)
[REF] link_tracker, mass_mailing: simplify add_click method and add tests
In this commit we rewrite a bit add_click in order to remove the inlined sudo and ease inheritance and parameter management inside the method. Access through controllers is sudo-ed as the main API method is now done with current user access rights. This commit is linked to task ID 1904277 and PR #28242.
Diffstat (limited to 'addons/link_tracker/controller/main.py')
-rw-r--r--addons/link_tracker/controller/main.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/addons/link_tracker/controller/main.py b/addons/link_tracker/controller/main.py
index 3b23c005446..d884967b5a6 100644
--- a/addons/link_tracker/controller/main.py
+++ b/addons/link_tracker/controller/main.py
@@ -8,9 +8,14 @@ from odoo.http import request
class LinkTracker(http.Controller):
+
@http.route('/r/<string:code>', type='http', auth='none', website=True)
def full_url_redirect(self, code, **post):
country_code = request.session.geoip and request.session.geoip.get('country_code') or False
- request.env['link.tracker.click'].sudo().add_click(code, request.httprequest.remote_addr, country_code, stat_id=False)
+ request.env['link.tracker.click'].sudo().add_click(
+ code,
+ ip=request.httprequest.remote_addr,
+ country_code=country_code
+ )
redirect_url = request.env['link.tracker'].get_url_from_code(code)
return werkzeug.utils.redirect(redirect_url or '', 301)