summaryrefslogtreecommitdiff
path: root/addons/project/models
diff options
context:
space:
mode:
authorYannick Tivisse <yti@odoo.com>2020-04-22 11:31:02 +0000
committerYannick Tivisse <yti@odoo.com>2020-04-22 11:32:35 +0000
commit85b199b9be57a9d175ef44bc85476a62cc437e16 (patch)
treeb4872622cd274cac59975c987271bdfd166905a7 /addons/project/models
parent45170ceeb5a90c06448b13b12bfaa67616225c32 (diff)
[IMP] various: Set a default random color on certain tags
Purpose ======= For a tag to be displayed on a kanban card, it needs to have a color set. We won't be changing that behaviour, since it would mean having two options > the color, and whether or not to show it in the kanban The purpose of this task is to set a color on new tags to make the user save a bit more time, set a color for him as he might not find the feature, and make sure the tag will be on the kanban cards. Specification ============= For each of the following models, at creation, set a random integer between 1 and 11 in field 'color' Models: res.partner.category crm.tag project.tags hr.applicant.category helpdesk.tag hr.employee.category event.track.tag mrp.eco.tag repair.tags closes odoo/odoo#49967 Taskid: 2234527 Related: odoo/enterprise#10112 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Diffstat (limited to 'addons/project/models')
-rw-r--r--addons/project/models/project.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/addons/project/models/project.py b/addons/project/models/project.py
index 2e73c760ab4..4da8ee5c2d0 100644
--- a/addons/project/models/project.py
+++ b/addons/project/models/project.py
@@ -3,6 +3,7 @@
import ast
from datetime import timedelta
+from random import randint
from odoo import api, fields, models, tools, SUPERUSER_ID, _
from odoo.exceptions import UserError, AccessError, ValidationError, RedirectWarning
@@ -1074,8 +1075,11 @@ class ProjectTags(models.Model):
_name = "project.tags"
_description = "Project Tags"
+ def _get_default_color(self):
+ return randint(1, 11)
+
name = fields.Char('Tag Name', required=True)
- color = fields.Integer(string='Color Index')
+ color = fields.Integer(string='Color Index', default=_get_default_color)
_sql_constraints = [
('name_uniq', 'unique (name)', "Tag name already exists!"),