odoo/upgrade-util#388

Created by Upgrade, Edoardo Piroli (pied)

Blocked

label
odoo-dev:master-update_record_from_xml_unset_missing_fields-pied
head
e56d99ae998bac6e4fc7c2623341e92d772adcd6
odoo/upgrade-util
master #388 missing statuses missing r+

[IMP] util.update_record_from_xml

Sometimes records get a field removed from their XML declaration. This creates a
divergence between new dbs and upgraded ones. The former will be initialised
with NULL/default values, whereas the latter will retain their current one.
This is usually handled in dedicated upgrade scripts with simple queries
un/setting the necessary columns. However, in some cases, these XML changes are
backported/noticed too late and need to be addressed in multiple versions.
That may create the pressure to target future versions, which creates a hidden
coupling between the xml declaration and the query, prone to turn into a bug.
It is one such example1 that inspired this PR.

Here update_record_from_xml is adapted to unset fields missing from the xml
declaration, if passed explicitely via the fields kwarg. This enables us to
leverage the foreward compatibility of update_record_from_xml in the scenario
described above, preventing the associated potential bugs.