summaryrefslogtreecommitdiff
path: root/addons/sales_team
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/sales_team
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/sales_team')
-rw-r--r--addons/sales_team/models/crm_tag.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/addons/sales_team/models/crm_tag.py b/addons/sales_team/models/crm_tag.py
index a0db292a292..205a7ada165 100644
--- a/addons/sales_team/models/crm_tag.py
+++ b/addons/sales_team/models/crm_tag.py
@@ -1,16 +1,20 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
+from random import randint
+
from odoo import fields, models
class Tag(models.Model):
-
_name = "crm.tag"
_description = "CRM 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 !"),