Skip to content

Commit

Permalink
[FIX] utm: dont try to set cookies if Response is Exception
Browse files Browse the repository at this point in the history
Also prefetch tracking_fields before the call to super to avoid to use a closed cursor.
See odoo/odoo@6780597

this commit closes odoo#13646
  • Loading branch information
JKE-be committed Oct 12, 2016
1 parent 6faf232 commit 7fb1b6f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion addons/utm/models/ir_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@ def get_utm_domain_cookies(self):
return request.httprequest.host

def _dispatch(self):
tracked_fields = self.pool['utm.mixin'].tracking_fields()

response = super(ir_http, self)._dispatch()
for var, dummy, cook in self.pool['utm.mixin'].tracking_fields():

# no set_cookie on Exception
if isinstance(response, Exception):
return response

for var, dummy, cook in tracked_fields:
if var in request.params and request.httprequest.cookies.get(var) != request.params[var]:
response.set_cookie(cook, request.params[var], domain=self.get_utm_domain_cookies())

return response

0 comments on commit 7fb1b6f

Please sign in to comment.