mirror of
https://github.com/bringout/oca-ocb-web.git
synced 2026-04-20 22:52:06 +02:00
Initial commit: Web packages
This commit is contained in:
commit
cd458d4b85
791 changed files with 410049 additions and 0 deletions
|
|
@ -0,0 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import ir_attachment
|
||||
from . import ir_qweb_fields
|
||||
from . import res_config_settings
|
||||
from . import res_users
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
# -*- 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)
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
from werkzeug import urls
|
||||
|
||||
from odoo import models, api
|
||||
|
||||
|
||||
class Image(models.AbstractModel):
|
||||
_inherit = 'ir.qweb.field.image'
|
||||
|
||||
@api.model
|
||||
def from_html(self, model, field, element):
|
||||
if element.find('.//img') is None:
|
||||
return False
|
||||
url = element.find('.//img').get('src')
|
||||
url_object = urls.url_parse(url)
|
||||
|
||||
if url_object.path.startswith('/unsplash/'):
|
||||
res_id = element.get('data-oe-id')
|
||||
if res_id:
|
||||
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
|
||||
|
||||
return super(Image, self).from_html(model, field, element)
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ResConfigSettings(models.TransientModel):
|
||||
_inherit = 'res.config.settings'
|
||||
|
||||
unsplash_access_key = fields.Char("Access Key", config_parameter='unsplash.access_key')
|
||||
unsplash_app_id = fields.Char("Application ID", config_parameter='unsplash.app_id')
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
from odoo import models
|
||||
|
||||
|
||||
class ResUsers(models.Model):
|
||||
_inherit = 'res.users'
|
||||
|
||||
def _can_manage_unsplash_settings(self):
|
||||
self.ensure_one()
|
||||
# Website has no dependency to web_unsplash, we cannot warranty the order of the execution
|
||||
# of the overwrite done in 5ef8300.
|
||||
# So to avoid to create a new module bridge, with a lot of code, we prefer to make a check
|
||||
# here for website's user.
|
||||
return self.has_group('base.group_erp_manager') or self.has_group('website.group_website_restricted_editor')
|
||||
Loading…
Add table
Add a link
Reference in a new issue