[FIX] website: access to themes images

Since 62c9dedafd, when accessing a website
connected as portal or public user, the themes images are not showed. An
error is arose 'Sorry, you are not allowed to access documents of type
'Attachment' (ir.attachment)'.

Now, the portal and public user have access to the themes images.

opw-2082468

closes odoo/odoo#39025

X-original-commit: 9b8c390cd5526556346356f260a9cfe1b90cd510
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
Co-authored-by: Lucas Perais <lpe@odoo.com>
This commit is contained in:
Jorge Pinna Puissant
2019-10-18 11:01:15 +00:00
committed by fw-bot
co-authored by Lucas Perais
parent e92d302d2f
commit d00a832952
+6 -1
View File
@@ -329,7 +329,12 @@ class Http(models.AbstractModel):
def _xmlid_to_obj(cls, env, xmlid):
website_id = env['website'].get_current_website()
if website_id and website_id.theme_id:
obj = env['ir.attachment'].search([('key', '=', xmlid), ('website_id', '=', website_id.id)])
domain = [('key', '=', xmlid), ('website_id', '=', website_id.id)]
Attachment = env['ir.attachment']
if request.env.user.share:
domain.append(('public', '=', True))
Attachment = Attachment.sudo()
obj = Attachment.search(domain)
if obj:
return obj[0]