[IMP] note: add default random color in tag

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) <tde@openerp.com>
This commit is contained in:
Mahamadasif Ansari
2022-12-19 09:28:13 +01:00
committed by Thibault Delavallée
parent ae0253da40
commit 51ac493044
+6 -1
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 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 !"),