* 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>
24 lines
809 B
Python
24 lines
809 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):
|
|
# Bypass the attachment create ACL and let the user create the image
|
|
# attachment if he has write right on the model (the image attachment
|
|
# will be bound to this model's record).
|
|
res_model = attachment_data['res_model']
|
|
res_id = attachment_data.get('res_id')
|
|
if (
|
|
res_model == 'forum.post' and res_id
|
|
and self.env['forum.post'].browse(res_id).can_use_full_editor
|
|
):
|
|
return True
|
|
|
|
return super()._can_bypass_rights_on_media_dialog(**attachment_data)
|