[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
This commit is contained in:
Thibault Delavallée
2020-12-11 18:12:19 +00:00
parent c0b7c78a8f
commit 43e474e663
2 changed files with 16 additions and 2 deletions
+7
View File
@@ -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 !"
+9 -2
View File
@@ -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 !"),
]