From 51ac493044ff02fb3eec53612e4776a716eadc18 Mon Sep 17 00:00:00 2001 From: Mahamadasif Ansari Date: Fri, 9 Dec 2022 05:31:24 +0000 Subject: [PATCH] [IMP] note: add default random color in tag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, when we creating a tag, it does not appear in the Kanban view because the tag does not have a default color.  This commit solve above problem by adding default random color in tag. task-3089296 closes odoo/odoo#107800 Signed-off-by: Thibault Delavallee (tde) --- addons/note/models/note.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/note/models/note.py b/addons/note/models/note.py index 33035da5d5a..e5e8b471a10 100644 --- a/addons/note/models/note.py +++ b/addons/note/models/note.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 api, fields, models, _ from odoo.tools import html2plaintext @@ -22,8 +24,11 @@ class Tag(models.Model): _name = "note.tag" _description = "Note Tag" + def _get_default_color(self): + return randint(1, 11) + name = fields.Char('Tag Name', required=True, translate=True) - color = fields.Integer('Color Index') + color = fields.Integer('Color Index', default=_get_default_color) _sql_constraints = [ ('name_uniq', 'unique (name)', "Tag name already exists !"),