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

**URL:** https://discuss.tryton.org/t/setting-multiple-linked-default-values-on-the-lines-depending-of-a-field-in-the-parent/949
**Category:** Developer
**Created:** [December 10, 2018, 9:08am UTC](https://discuss.tryton.org/t/setting-multiple-linked-default-values-on-the-lines-depending-of-a-field-in-the-parent/949 "2018-12-10T09:08:31Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![maxx](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/maxx/32/2320_2.png) [@maxx](https://discuss.tryton.org/u/maxx)
#### Post date: [December 10, 2018, 9:08am UTC](https://discuss.tryton.org/t/setting-multiple-linked-default-values-on-the-lines-depending-of-a-field-in-the-parent/949/1 "2018-12-10T09:08:31Z")

</div>

Hi,

I’m using incoterm module from Nan-Tic ([https://bitbucket.org/nantic/trytond-incoterm/src](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 !

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [December 10, 2018, 11:10am UTC](https://discuss.tryton.org/t/setting-multiple-linked-default-values-on-the-lines-depending-of-a-field-in-the-parent/949/2 "2018-12-10T11:10:35Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![maxx](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/maxx/32/2320_2.png) [@maxx](https://discuss.tryton.org/u/maxx)
#### Post date: [December 10, 2018, 12:30pm UTC](https://discuss.tryton.org/t/setting-multiple-linked-default-values-on-the-lines-depending-of-a-field-in-the-parent/949/3 "2018-12-10T12:30:54Z")

</div>

Exactly what i need 🙂 Thanks !

---

<div class="post-metadata">

### Author: ![system](https://discuss-cdn.tryton.org/uploads/default/original/1X/c6f8ec0a40525cdcd50058c734283450a4b3d38b.png) [@system](https://discuss.tryton.org/u/system)
#### Post date: [January 9, 2019, 12:37pm UTC](https://discuss.tryton.org/t/setting-multiple-linked-default-values-on-the-lines-depending-of-a-field-in-the-parent/949/4 "2019-01-09T12:37:03Z")

</div>

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