mirror of
https://github.com/bringout/oca-ocb-web.git
synced 2026-04-19 18:32:07 +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,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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue