summaryrefslogtreecommitdiff
path: root/addons/website_event_track/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/website_event_track/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/website_event_track/models')
-rw-r--r--addons/website_event_track/models/event_track.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/addons/website_event_track/models/event_track.py b/addons/website_event_track/models/event_track.py
index 205b8e4e969..31054d09855 100644
--- a/addons/website_event_track/models/event_track.py
+++ b/addons/website_event_track/models/event_track.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.translate import _, html_translate
from odoo.addons.http_routing.models.ir_http import slug
@@ -12,9 +14,14 @@ class TrackTag(models.Model):
_description = 'Event Track Tag'
_order = 'name'
+ def _get_default_color(self):
+ return randint(1, 11)
+
name = fields.Char('Tag Name', required=True)
track_ids = fields.Many2many('event.track', string='Tracks')
- color = fields.Integer(string='Color Index', help="Note that colorless tags won't be available on the website.")
+ color = fields.Integer(
+ string='Color Index', default=_get_default_color,
+ help="Note that colorless tags won't be available on the website.")
_sql_constraints = [
('name_uniq', 'unique (name)', "Tag name already exists !"),