2016-04-12 9:09 GMT+02:00 Markus Bala <markusb...@gmail.com>: > > > On Tue, Apr 12, 2016 at 1:58 PM, Ralf Peschke <rpesc...@peschke-it.de> > wrote: >> >> Hi Markus, >> >> Am 12.04.2016 um 05:55 schrieb Markus Bala: >> > Hi, >> > >> > I had an inherit model ShipmentIn. Adding new field "order_confirm". The >> > purpose when the order confirmed, other fields will be readonly. >> > >> > How I am going to modify other fields base on the "order_confirm"? >> > >> > Example: >> > Original : >> > company = fields.Many2One(.., states ={'readonly': Eval('state') != >> > 'draft'}) >> > >> > Expected: >> > company = fields.Many2One(..., states = {'readonly': Eval('state') != >> > 'draft' | Eval('order_confirm') } >> > >> The "states" of each field are a dictionary with the keys "readonly", >> "required" and "invisible". You can change it in the setup-classmethod: >> >> @classmethod >> def __setup__(cls): >> super(YOURCLASSNAME, cls).__setup__() >> cls.company.states['readonly'] = (Eval('state') != 'draft' | >> Eval('order_confirm')) >> >> >> I hope it helps in time > > > Hi Ralf, > > Thank you. > > If let say I do not want to change the original state but only add the new > condition. Is it possible? > > original_condition = cls.company.states['readonly'] > cls.company.states['readonly'] = (original_condition | > Eval('order_confirm'))
And example inherit in __setup__(cls): cls.shipment.states['readonly'] |= Eval('moves', False) In your code (without tested): cls.company.states['readonly'] |= Eval('order_confirm') Raimon -- You received this message because you are subscribed to the Google Groups "tryton-dev" group. To view this discussion on the web visit https://groups.google.com/d/msgid/tryton-dev/CALO_w6r_ykBnBQiq9dpPsQbUrfgVwij_SMac01CKnhxk8xiNMw%40mail.gmail.com.