XML and Model.data synchronization

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?

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?

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.

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.

Also avoid to use XML to load initial setup data (see Issue 8346: Load and update pycountry data from script - Tryton issue tracker).