* web_unsplash, website_forum With [1], the access errors when a portal user were using the media dialog got fixed. It also came with the unsplash capability for portal user in the media dialog. Still, there was a remaining problematic point: an internal user can't upload an unsplash image in the backend through the media dialog. It doesn't really make sense for an internal user to have less right than the portal user. This commit corrects that part. Note that only unsplash images were problematic, not regular uploaded image as the difference was that unsplash images attachment are saved with an `url` property, which was triggering due to [2]. Finally, it was chosen to make that "bypass" more robust and opt in, so forum and unsplash are allowing their use cases to go through, it's not done in a generic way anymore. Also fixing a small issue about the res_id not being sent when editing a forum post, because it was assuming that the URL would end with the ID which is not the case when you edit your answer. [1]: https://github.com/odoo/odoo/commit/e10493711879c7f0cc8832db3f1936c622ea605c [2]: https://github.com/odoo/odoo/commit/bfffe39f1376a56226572295b945a2cc73ba50ce task-3007844 closes odoo/odoo#103138 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
19 lines
708 B
Python
19 lines
708 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import models
|
|
|
|
|
|
class Attachment(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)
|