oca-ocb-web/odoo-bringout-oca-ocb-web_unsplash/web_unsplash/models/ir_attachment.py
Ernad Husremovic 4b94f0abc5 19.0 vanilla
2026-03-09 09:32:58 +01:00

17 lines
709 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
class IrAttachment(models.Model):
_inherit = "ir.attachment"
def _can_bypass_rights_on_media_dialog(self, **attachment_data):
# We need to allow and sudo the case of an "url + file" attachment,
# which is by default forbidden for non admin.
# See `_check_serving_attachments`
forbidden = 'url' in attachment_data and attachment_data.get('type', 'binary') == 'binary'
if forbidden and attachment_data['url'].startswith('/unsplash/'):
return True
return super()._can_bypass_rights_on_media_dialog(**attachment_data)