From f7b957f61110775c85b6a5ee72f52e8519de65ff Mon Sep 17 00:00:00 2001 From: diagnoza Date: Wed, 12 Jan 2022 11:10:48 +0000 Subject: [PATCH] [FIX] website: ensure unicity of find Before https://github.com/odoo/odoo/commit/254d40ffcc21f56a80a1814da7f6355d44e5670b it was possible that when a user cropped an image using the crop tool, a copy of the original image was created that had both original_id and theme_template_id carried over, therefore find could be multi-record. We strengthen that search by adding original_id=False, which ensures we always fetch the record of the original image and not also its copies. In addition, databases that happen to have this issue of corrupted data will be fixed during an upgrade with https://github.com/odoo/upgrade/pull/3110. closes odoo/odoo#82725 X-original-commit: e4bb0cd4466404e2fba62ae2d3bbaebd831fbcb2 Signed-off-by: Christophe Simonis --- addons/website/models/ir_module_module.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/website/models/ir_module_module.py b/addons/website/models/ir_module_module.py index 6d1e15a59b6..a563a9efa85 100644 --- a/addons/website/models/ir_module_module.py +++ b/addons/website/models/ir_module_module.py @@ -153,7 +153,9 @@ class IrModuleModule(models.Model): # special case for attachment # if module B override attachment from dependence A, we update it if not find and model_name == 'ir.attachment': - find = rec.copy_ids.search([('key', '=', rec.key), ('website_id', '=', website.id)]) + # In master, a unique constraint over (theme_template_id, website_id) + # will be introduced, thus ensuring unicity of 'find' + find = rec.copy_ids.search([('key', '=', rec.key), ('website_id', '=', website.id), ("original_id", "=", False)]) if find: imd = self.env['ir.model.data'].search([('model', '=', find._name), ('res_id', '=', find.id)])