kakamble
(Kshitij Kamble)
1
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
pokoli
(Sergi Almacellas Abellana)
2
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
kakamble
(Kshitij Kamble)
3
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!
system
(system)
Closed
4
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.