Setting multiple linked default values on the lines depending of a field in the parent


(Maxime Richez) #1

Hi,

I’m using incoterm module from Nan-Tic (https://bitbucket.org/nantic/trytond-incoterm/src). With this module, we could define a default incoterm and incoterm place for a party.
In a custom module, with a model parent-child, i’ve a supplier field in the parent class and i would like to get default values depending of the supplier field on the lines for the fields incoterm and incoterm place. Usually those two fields are updated with a method on_change on the supplier/party. But in my case, supplier become readonly when there is lines, and i would like each new line with default values for both fields.
Thanks for help !


(Sergi Almacellas Abellana) #2

You should use on_change_parent to set the values depending on the supplier field of the parent class. Each time you create a new child model, the parent field will be set automatically by the client and it will call the on_change_ methods which can be used to set the default values reading the parent values.

Hope it helps.


(Maxime Richez) #3

Exactly what i need :slight_smile: Thanks !


(system) #4

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.