How to set states on a group element

Good afternoon,
I am trying to set a group into invisible trough the states property on tryton 5.0.

We have done something like this, but it gives me some error

<field name="has_signs"/>
<group string="Signs" id="contact_signs" colspan="4" states="{'invisible': Not(Bool(Eval('has_signs')))}">
 (......)
 </group>

The traceback last line gives me this
JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)

Is there any example on any module to get some idea on how it works?

Thanks

You can not use PYSON statements on XML fileds without encoding them.
In order to do so you should use the view_attributes method of the class to do so. There is an example on the account_invoice module.

Hope it helps.

1 Like

It was!!! Thank you very much.
The result is

@classmethod
def view_attributes(cls):
    return [('/form/group[@id="contact_signs"]', 'states', {
                'invisible':Not(Bool(Eval('has_signs'))),
            })]

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.