Skip to content

Commit

Permalink
[FIX] website: ensure unicity of find
Browse files Browse the repository at this point in the history
Before odoo@254d40f 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 odoo/upgrade#3110.

closes odoo#82714

X-original-commit: e4bb0cd
Signed-off-by: Christophe Simonis <chs@odoo.com>
  • Loading branch information
diagnoza committed Jan 13, 2022
1 parent a101ead commit 2296746
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion addons/website/models/ir_module_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ def _update_records(self, model_name, website):
# 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)])
Expand Down

0 comments on commit 2296746

Please sign in to comment.