From d24b5038a0e4ae34e745cac74621929dfd9d49c8 Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Tue, 5 Apr 2016 15:00:07 +0200 Subject: [PATCH] [FIX] utm: ignore utm for saleman. When a saleman create a lead or a sale after clicking on a link to test their own campaign, they don't want to be linked to this campaign --- addons/utm/models/utm.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/utm/models/utm.py b/addons/utm/models/utm.py index b660a9c1dbc..8e98c95b2ac 100644 --- a/addons/utm/models/utm.py +++ b/addons/utm/models/utm.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, fields, models +from odoo import api, fields, models, SUPERUSER_ID from odoo.http import request @@ -60,6 +60,10 @@ class UtmMixin(models.AbstractModel): def default_get(self, fields): values = super(UtmMixin, self).default_get(fields) + # We ignore UTM for salemen, except some requests that could be done as superuser_id to bypass access rights. + if self.env.uid != SUPERUSER_ID and self.env.user.has_group('base.group_sale_salesman'): + return values + for url_param, field_name, cookie_name in self.env['utm.mixin'].tracking_fields(): if field_name in fields: field = self._fields[field_name]