summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorSamuel Degueldre <sad@odoo.com>2020-02-24 13:46:43 +0000
committerJeremy Kersten <jke@odoo.com>2020-04-22 08:55:32 +0000
commita39c90fd6dbde841d618cbd3f3848926b1e2bc5b (patch)
tree1380d66b76bd3b5e7bda560124e02ad29075d57b /addons
parentaf70d192653d9751cf912b9e8747a942f38514a4 (diff)
[FIX] web_unsplash: unsplash images added on website break on products
Before this commit, selecting an unsplash image on website, then going on a product page and selecting that same image in the media-dialog would not work, and upon saving, the image would be the image placeholder. A previous fix in odoo/odoo#31328 added handling so that you could choose unsplash images for a product, but it failed to account for unsplash images that had already been added on a public view (for example on a website page), which the user can choose in the media-dialog. This was caused by the fix only searching for the unsplash attachment on the current model, and not among public attachments, resulting in an empty search result. This commit fixes that by adding that the attachment we are looking for should either be on the current model, or be a public attachment. closes odoo/odoo#49937 X-original-commit: 196d6b1630fa443bc1d143f76f62f7a719ca4930 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com> Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/web_unsplash/models/ir_qweb.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/addons/web_unsplash/models/ir_qweb.py b/addons/web_unsplash/models/ir_qweb.py
index 79efb8e0b2b..9b0f60a44ab 100644
--- a/addons/web_unsplash/models/ir_qweb.py
+++ b/addons/web_unsplash/models/ir_qweb.py
@@ -19,8 +19,10 @@ class Image(models.AbstractModel):
res_id = int(res_id)
res_model = model._name
attachment = self.env['ir.attachment'].search([
+ '&', '|', '&',
('res_model', '=', res_model),
('res_id', '=', res_id),
+ ('public', '=', True),
('url', '=', url_object.path),
], limit=1)
return attachment.datas