Dear Tryton team,
I want to keep all my fields on read-only once the state of my inspection is done, using the states and Eval seems to work, unfortunately for the One2Many fields I can’t figure it out how to eval a field from my source class, here’s the example:
class Inspection(ModelSQL, ModelView):
'Inspection'
__name__ = 'my.module.inspection'
STATES = {'readonly': Eval('state') == 'done'} # this work for inspection fields
# details are readonly but I still can change description field
details = fields.One2Many(
'my.module.details',
'inspection', 'Inspection details',
states = STATES)
class Details(ModelSQL, ModelView):
'Details'
__name__ = 'my.module.details'
inspection = fields.Many2One(
'my.module.inspection', 'inspection', readonly=True)
STATES= ???
# I tried below states but does not seem to work
#STATES = {'readonly': Eval('inspection.state') == 'done'}
#STATES = {'readonly': Eval('_parent_inspection.state') == 'done'} # I know this is close
description = fields.Char('Descripcion', states=STATES)
Any clue will be appreciated. btw the Inspection class is part of a module, which inheritance from the parent module that has the state field