From 43e474e663b76b96a59cc24869484d042de24785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 11 Dec 2020 09:16:14 +0000 Subject: [PATCH] [FIX] utm: show campaign tags by default by giving them a color Colorless tags are not displayed in kanban view of utm campaigns. When creating tags on the fly currently they have no color and are therefore not displayed once saving the campaign. This is not really intuitive for users. We now set a default value to color field of tags. They are now displayed by defauklt. LINKS Task ID-2300385 COM PR odoo/odoo#59872 ENT PR odoo/enterprise#14031 X-original-commit: 4f83be33d4cc53d50081050b3a9dee2892c562a4 --- addons/utm/i18n/utm.pot | 7 +++++++ addons/utm/models/utm.py | 11 +++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/addons/utm/i18n/utm.pot b/addons/utm/i18n/utm.pot index f8d5629bb5a..c0392cbe3e8 100644 --- a/addons/utm/i18n/utm.pot +++ b/addons/utm/i18n/utm.pot @@ -554,6 +554,13 @@ msgid "" "progress, done, …)." msgstr "" +#. module: utm +#: model:ir.model.fields,help:utm.field_utm_tag__color +msgid "" +"Tag color. No color means no display in kanban to distinguish internal tags " +"from public categorization tags." +msgstr "" + #. module: utm #: model:ir.model.constraint,message:utm.constraint_utm_tag_name_uniq msgid "Tag name already exists !" diff --git a/addons/utm/models/utm.py b/addons/utm/models/utm.py index 3c197d1814e..0bf712c4be4 100644 --- a/addons/utm/models/utm.py +++ b/addons/utm/models/utm.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. +from random import randint + from odoo import fields, models, api, SUPERUSER_ID @@ -64,9 +66,14 @@ class UtmTag(models.Model): _description = 'UTM Tag' _order = 'name' + def _default_color(self): + return randint(1, 11) + name = fields.Char(required=True, translate=True) - color = fields.Integer(string='Color Index') + color = fields.Integer( + string='Color Index', default=lambda self: self._default_color(), + help='Tag color. No color means no display in kanban to distinguish internal tags from public categorization tags.') _sql_constraints = [ - ('name_uniq', 'unique (name)', "Tag name already exists !"), + ('name_uniq', 'unique (name)', "Tag name already exists !"), ]