Hello, everybody, how are you doing today?
I am attempting to add random colours to my custom tags, and it is
working well. However, I want more colour options to select
from in Odoo. Is it possible to generate random colours and allocate
them to the tags in a manner that Odoo can recognise them? Below is a
functioning solution using the limited colours Odoo offers (11 indexes):
---
import random
from odoo import fields, models
class EstatePropertyTag(models.Model):
_name = "estate.property.tag"
_description = "Real Estate Property Tag"
_sql_constraints = [
("check_unique_name", "UNIQUE(name)", "The name must be unique"),
]
name = fields.Char("Name", required=True)
color = fields.Integer(string="Color Index")
property_ids = fields.Many2many("estate.property", "property_tag_id", string="Properties")
def create(self, vals):
vals['color'] = random.randint(1, 11)
result = super(EstatePropertyTag, self).create(vals)
return result
---
Please let me know if there is any sort of solution to randomly add hexadecimal colour values to Odoo tags or to extend Odoo's colour index list. Thank you and have a great time!