was looking through various modules in tryton. but i was not able to find Eval that is using function to evaluate ? is it possible to do that ? or do i have create function field along with getter ?
what are the others option avaliable ?
Do not understand what do you mean by “using function to evaluate” but Eval only accepts fields from the current model (no functions) or related fields using dot notation (Since https://hg.tryton.org/trytond/rev/6fe6d9056f29)
So this are the only options.
suppose i am having this one field with states
gst_no = fields.Char("GST No.", select=True, help="GST No",states = {'invisible': myfunction })
def myfunction()
#My logic here
#Return True or False
is something similar possible ?
i can acess relation in one2many fields ? and compare the value ? so i don’t have to write logic in fields.depends
You should use a boolean fields that computes the invisible. Something like:
gst_no = fields.Char("GST No.", select=True, help="GST No",
states = {'invisible': Eval('gst_no_is_invisible'})
gst_no_is_invisible = fields.Function(fields.Boolean("GST No is Invisible",
'on_change_with_gst_no_is_invisible')
@fields.depends()
def on_change_with_gst_no_is_invisible(self, name):
#My logic here
#Return True or False
Note that I used an on_change_with so the function is recomputed whenever the user changes some fields on the records.