On 2016-05-24 08:01, Maxime Richez wrote:
>
>
> >
> > I think in this case, it is better to define a default one on the parent
> > and use the on_change like @pokoli said to change the default value to
> > this default defined on the parent.
> >
> >
>
> I follow your advice but how to force the "on_change_with" be executed and
> set the default value when the form is opened ? Here's is the code of my on
> change:
>
> @fields.depends('_parent_purchase_requisition.currency')
> def on_change_with_currency(self):
> currency = self.purchase_requisition.currency if
> self.purchase_requisition
> else None
> if currency:
> return currency.id
> else:
> Company = Pool().get('company.company')
> company = Transaction().context.get('company')
> if company:
> company = Company(company)
> return company.currency.id
I think if I remember correctly, you must add 'purchase_requisition' in
the depends.
--
Cédric Krier - B2CK SPRL
Email/Jabber: [email protected]
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/
--
You received this message because you are subscribed to the Google Groups
"tryton" group.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tryton/20160524152544.GD13326%40tetsuo.