odoo/upgrade-util#253

Created by Upgrade, Alvaro Fuentes Suarez (afu)

Blocked

label
odoo-dev:master-imp_avoid_error-afu
head
133d8595dd7a97bcc5354c3732ae5fbe1e487155
odoo/upgrade-util
master #253 missing r+

[IMP] util/records: skip replace if all ids are the same

If all ids are the same and we are replacing in the same model we
currently cause an error. This is not necessary and could lead to false
errors if the list of mapping ids is correctly the same.

For example sometimes we transform a model A into model B by updating
metadata. Then we insert into B's table, and finally perform a replace
of references from A's table to B's table. This would fail if the ids
are the same. This case will happen with a high probability if there is
only one A record with id=1 since the single B record would get id=1 as
well.

Example logs after the patch:

2025-04-14 07:28:32,883 42811 WARNING test_16 odoo.upgrade.util.records: Replace references in model `res.country`, ignoring same-id mapping `{1: 1, 2: 2}`
2025-04-14 07:28:32,883 42811 WARNING test_16 odoo.upgrade.util.records: Nothing to replace in model `res.country`, ignoring empty mapping