# XML and Model.data synchronization

**URL:** https://discuss.tryton.org/t/xml-and-model-data-synchronization/3348
**Category:** Developer
**Created:** [October 13, 2020, 6:17pm UTC](https://discuss.tryton.org/t/xml-and-model-data-synchronization/3348 "2020-10-13T18:17:14Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![rvong](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/r/3bc359/32.png) [@rvong](https://discuss.tryton.org/u/rvong)
#### Post date: [October 13, 2020, 6:17pm UTC](https://discuss.tryton.org/t/xml-and-model-data-synchronization/3348/1 "2020-10-13T18:17:14Z")

</div>

Hello to Everyone,

I would like to know when we create some records in a XML file inside a module, for example adding some ir.trigger events or some default products, and we modify this data after the module was activated, the DB needs to be updated with a manual update like:

`    
trytond-admin -c config -u module_name -d db_name
`

Sometimes the XML new data gets updated to their respective models, and sometimes they don’t and one have to go into _Administration-\>Models-\>Models-\>Data_ and look for “out of sync” resources and manually click on “Sync” to synchronize them.

So what I would like to know is under what conditions do these resources requires the manual Sync and when do they update automatically?

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [October 13, 2020, 9:29pm UTC](https://discuss.tryton.org/t/xml-and-model-data-synchronization/3348/2 "2020-10-13T21:29:58Z")

</div>

> [@rvong](#):
>
> So what I would like to know is under what conditions do these resources requires the manual Sync and when do they update automatically?

It is required if the initial XML data were not canonical. For example if you define an integer for a float.

---

<div class="post-metadata">

### Author: ![rvong](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/r/3bc359/32.png) [@rvong](https://discuss.tryton.org/u/rvong)
#### Post date: [October 13, 2020, 10:31pm UTC](https://discuss.tryton.org/t/xml-and-model-data-synchronization/3348/3 "2020-10-13T22:31:59Z")

</div>

> [@ced](#):
>
> It is required if the initial XML data were not canonical. For example if you define an integer for a float.

So, if I remove or fix those “non-canonical” data from the XML, it will then update automatically every time. Is that correct?

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [October 14, 2020, 7:06am UTC](https://discuss.tryton.org/t/xml-and-model-data-synchronization/3348/4 "2020-10-14T07:06:13Z")

</div>

If you want to avoid such issue, you must never remove any `<field/>` declaration because `trytond` could not compare with something that does not exist anymore.

---

<div class="post-metadata">

### Author: ![rvong](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/r/3bc359/32.png) [@rvong](https://discuss.tryton.org/u/rvong)
#### Post date: [October 14, 2020, 2:14pm UTC](https://discuss.tryton.org/t/xml-and-model-data-synchronization/3348/5 "2020-10-14T14:14:03Z")

</div>

Thanks you for the hints. So in summary, to avoid the issue of manual sync we must for the XML data:

1. Avoid non-canonical data, i.e. if the field expects a “Decimal” then we do ` eval=“Decimal(‘1.00’)”` instead of ` eval=“1.00” `
2. Avoid removing declared `<field/>` on subsequent changes. But if they are removed because the model definition changed, then a manual sync is needed and unavoidable.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [October 14, 2020, 2:17pm UTC](https://discuss.tryton.org/t/xml-and-model-data-synchronization/3348/6 "2020-10-14T14:17:44Z")

</div>

Also avoid to use XML to load initial setup data (see [Load and update pycountry data from script (#8346) · Issues · Tryton / Tryton · GitLab](https://bugs.tryton.org/issue8346)).
