upgrade-util icon indicating copy to clipboard operation
upgrade-util copied to clipboard

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

Open aj-fuentes opened this issue 8 months ago • 1 comments

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

aj-fuentes avatar Apr 14 '25 14:04 aj-fuentes

Pull request status dashboard

robodoo avatar Apr 14 '25 14:04 robodoo