Help needed in notebook page states

How is states written in notebook page tag in XML?

I have tried the following

<page id="_renumeration" string="Renumeration Bills"
        states="{
        'readonly': ~Eval('state').in_(['draft']),
        'invisible': Eval('state').in_([
            'draft',
            'confirm',
            'approved',
            'in_progress'
        ])
    }" pyson="1">

but it doesn’t work.

Help is much appreciated

PYSON statements can not be used on xml defintion but it should be defined on python code by using the view_attributes function. You have an example of it’s usage on the invoice module

Hope it helps!

1 Like

Thanks! It helped!

In the model, I wrote a separate dictionary for states

_RENUM_PAGE_STATES = {
    'readonly': ~Eval('state').in_(['draft']),
    'invisible': Eval('state').in_([
        'draft',
        'confirm',
    ])
}

then in view_attributes, I wrote the follwing

@classmethod
def view_attributes(cls):
    return [('/form/notebook/page[@id="_renumeration"]', 'states', cls._RENUM_PAGE_STATES)]

Works perfectly!

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