Commit d978d47
committed
[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 example[^1] 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.
[^1]: odoo/upgrade#95121 parent b0fb61b commit d978d47
1 file changed
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1039 | 1039 | | |
1040 | 1040 | | |
1041 | 1041 | | |
1042 | | - | |
| 1042 | + | |
| 1043 | + | |
1043 | 1044 | | |
1044 | 1045 | | |
1045 | 1046 | | |
| |||
1147 | 1148 | | |
1148 | 1149 | | |
1149 | 1150 | | |
| 1151 | + | |
1150 | 1152 | | |
1151 | 1153 | | |
1152 | 1154 | | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
1153 | 1158 | | |
1154 | 1159 | | |
1155 | 1160 | | |
| |||
0 commit comments