Use cls.view_attributes() to define states in views

This commit is contained in:
Guillem Barba 2016-04-14 01:58:07 +02:00
parent ca24139d27
commit aef47441f4
2 changed files with 15 additions and 2 deletions

View File

@ -340,3 +340,16 @@ class Asset:
@staticmethod
def default_conductors_connection():
return ''
@classmethod
def view_attributes(cls):
res = super(Asset, cls).view_attributes()
res += [
('/form/separator[@id="elevator"]', 'states', {
'invisible': Eval('type') != 'elevator',
}),
('/form/notebook/page[@id="components"]', 'states', {
'invisible': Eval('type') != 'elevator',
}),
]
return res

View File

@ -3,7 +3,7 @@
copyright notices and license terms. -->
<data>
<xpath expr="/form/notebook" position="before">
<separator id="elevator" string="Elevator Info" states="{'invisible': Eval('type') != 'elevator'}" colspan="4"/>
<separator id="elevator" string="Elevator Info" colspan="4"/>
<group col="6" colspan="4" id="elevator_info">
<label name="elevator_type"/>
<field name="elevator_type"/>
@ -28,7 +28,7 @@
</group>
</xpath>
<xpath expr="/form/notebook" position="inside">
<page id="components" string="Components" col="2" states="{'invisible': Eval('type') != 'elevator'}">
<page id="components" string="Components" col="2">
<group id="doors_limiter" col="1">
<group id="doors" col="2">
<separator id="doors" string="Doors" colspan="2"/>