fixed Color Picker in machine_area_views
This commit is contained in:
parent
943d2cfe43
commit
a23afea36d
|
|
@ -377,15 +377,57 @@ class OwsUser(models.Model):
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
AVAILABLE_COLORS = [
|
||||||
|
('#000000', 'schwarz'),
|
||||||
|
('#ff0000', 'Rot'),
|
||||||
|
('#E91E63', 'Pink'),
|
||||||
|
('#9C27B0', 'Lila'),
|
||||||
|
('#3F51B5', 'Indigo'),
|
||||||
|
('#0000ff', 'Blau'),
|
||||||
|
('#008000', 'Grün'),
|
||||||
|
('#ffff00', 'Gelb'),
|
||||||
|
('#FF9800', 'Orange'),
|
||||||
|
('#795548', 'Braun'),
|
||||||
|
('#ffffff', 'Weiss'),
|
||||||
|
]
|
||||||
|
|
||||||
class OwsMachineArea(models.Model):
|
class OwsMachineArea(models.Model):
|
||||||
_name = 'ows.machine.area'
|
_name = 'ows.machine.area'
|
||||||
_table = "ows_machine_area"
|
_table = 'ows_machine_area'
|
||||||
_description = 'OWS: Maschinenbereich'
|
_description = 'OWS: Maschinenbereich'
|
||||||
_order = 'name'
|
_order = 'name'
|
||||||
|
|
||||||
name = fields.Char(required=True, translate=True)
|
name = fields.Char(string="Name", required=True, translate=True)
|
||||||
#color = fields.Integer(string="Farbe")
|
|
||||||
color_hex = fields.Char(string="Farbe (Hex)", help="Hex-Farbcode wie #FF0000 für Rot")
|
color_hex = fields.Selection(
|
||||||
|
selection=AVAILABLE_COLORS,
|
||||||
|
string="Farbe (Hex)",
|
||||||
|
required=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
color_hex_value = fields.Char(
|
||||||
|
string="Farbcode",
|
||||||
|
compute='_compute_color_hex_value',
|
||||||
|
store=False
|
||||||
|
)
|
||||||
|
|
||||||
|
color_name = fields.Char(
|
||||||
|
string="Farbname",
|
||||||
|
compute='_compute_color_name',
|
||||||
|
store=False
|
||||||
|
)
|
||||||
|
|
||||||
|
@api.depends('color_hex')
|
||||||
|
def _compute_color_hex_value(self):
|
||||||
|
for rec in self:
|
||||||
|
rec.color_hex_value = rec.color_hex or ''
|
||||||
|
|
||||||
|
@api.depends('color_hex')
|
||||||
|
def _compute_color_name(self):
|
||||||
|
label_dict = dict(AVAILABLE_COLORS)
|
||||||
|
for rec in self:
|
||||||
|
rec.color_name = label_dict.get(rec.color_hex, 'Unbekannt')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class OwsMachine(models.Model):
|
class OwsMachine(models.Model):
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree>
|
<tree>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="color_hex" widget="color_picker"/>
|
<field name="color_hex_value" string="Farbe (Hex)"/>
|
||||||
|
<field name="color_name" string="Farbname"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
@ -30,7 +31,8 @@
|
||||||
<form string="Maschinenbereich">
|
<form string="Maschinenbereich">
|
||||||
<group>
|
<group>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="color_hex" widget="color_picker"/>
|
<field name="color_hex"/>
|
||||||
|
<field name="color_name" readonly="1"/>
|
||||||
</group>
|
</group>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user