Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save litnimax/5c03ef02da86f350107a8efe938c4e7e to your computer and use it in GitHub Desktop.
Save litnimax/5c03ef02da86f350107a8efe938c4e7e to your computer and use it in GitHub Desktop.
Color convert int to css for odoo
@api.multi
def _get_kanban_color(self):
for self in self:
if not self.area_color:
continue
css = self.area_color[1:]
r,g,b = int(css[:2], 16), int(css[2:4], 16), int(css[4:], 16)
RGBint = (r<<16) + (g<<8) + b
self.kanban_color = RGBint
@api.multi
def _set_kanban_color(self):
for self in self:
if not self.kanban_color:
continue
RGBint = self.kanban_color
b = RGBint & 255
g = (RGBint >> 8) & 255
r = (RGBint >> 16) & 255
self.color = '#{}{}{}'.format(r, g, b)
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment