Skip to content

Commit a07a858

Browse files
committed
[FIX] link_tracker: fix missing query params in redirect url
If the target url had duplicate keys in its query params, the redirect url would only contain the key-value pair corresponding to the first occurrence of the key. This is incorrect, as a shop url typically contains multiple attribute values in its query params. The issue was caused by an accidental cast from MultiDict to Dict when handling the query params. opw-4466925 closes odoo#199570 Signed-off-by: Louis Tinel (loti) <loti@odoo.com>
1 parent 05e5a90 commit a07a858

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

addons/link_tracker/models/link_tracker.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# -*- coding: utf-8 -*-
21
# Part of Odoo. See LICENSE file for full copyright and licensing details.
32

43
import random
5-
import requests
64
import string
75

6+
import requests
7+
88
from lxml import html
99
from werkzeug import urls
1010

11-
from odoo import tools, models, fields, api, _
11+
from odoo import _, api, fields, models, tools
1212
from odoo.exceptions import UserError
1313
from odoo.osv import expression
1414

@@ -102,16 +102,15 @@ def _compute_redirected_url(self):
102102
tracker.redirected_url = parsed.to_url()
103103
continue
104104

105-
utms = {}
105+
query = parsed.decode_query()
106106
for key, field_name, cook in self.env['utm.mixin'].tracking_fields():
107107
field = self._fields[field_name]
108108
attr = tracker[field_name]
109109
if field.type == 'many2one':
110110
attr = attr.name
111111
if attr:
112-
utms[key] = attr
113-
utms.update(parsed.decode_query())
114-
tracker.redirected_url = parsed.replace(query=urls.url_encode(utms)).to_url()
112+
query[key] = attr
113+
tracker.redirected_url = parsed.replace(query=urls.url_encode(query)).to_url()
115114

116115
@api.model
117116
@api.depends('url')

0 commit comments

Comments
 (0)