mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-26 18:38:41 -06:00
[MIG]Port v10
This commit is contained in:
parent
afbab2fb29
commit
f1040fbd3f
@ -40,7 +40,9 @@ Contributors
|
|||||||
------------
|
------------
|
||||||
|
|
||||||
* Jonathan Nemry <jonathan.nemry@acsone.eu>
|
* Jonathan Nemry <jonathan.nemry@acsone.eu>
|
||||||
* Pedro M. Baeza <pedro.baeza@tecnativa.com
|
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
|
||||||
|
* Nicolás Ramos <contacto@difusionvisual.com>
|
||||||
|
* Antonio Cánovas <antonio.canovas@ingenieriacloud.com>
|
||||||
|
|
||||||
Maintainer
|
Maintainer
|
||||||
----------
|
----------
|
||||||
|
@ -19,5 +19,5 @@
|
|||||||
'qweb': [
|
'qweb': [
|
||||||
'static/src/xml/url.xml',
|
'static/src/xml/url.xml',
|
||||||
],
|
],
|
||||||
'installable': False,
|
'installable': True,
|
||||||
}
|
}
|
||||||
|
3
document_url/static/src/css/url.css
Normal file
3
document_url/static/src/css/url.css
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
-.oe_url_attachment{
|
||||||
|
- padding: 3px 20px;
|
||||||
|
-}
|
@ -2,7 +2,7 @@
|
|||||||
<templates id="template" xml:space="preserve">
|
<templates id="template" xml:space="preserve">
|
||||||
<t t-name="AddUrlDocumentItem">
|
<t t-name="AddUrlDocumentItem">
|
||||||
<li class="oe_sidebar_add_url">
|
<li class="oe_sidebar_add_url">
|
||||||
<a class="oe_file_attachment">Add URL...</a>
|
<span class="oe_url_attachment">Add URL...</span>
|
||||||
</li>
|
</li>
|
||||||
</t>
|
</t>
|
||||||
</templates>
|
</templates>
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<openerp>
|
<odoo>
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
<template id="assets_backend" name="google_drive assets" inherit_id="web.assets_backend">
|
<template id="assets_backend" name="google_drive assets" inherit_id="web.assets_backend">
|
||||||
<xpath expr="." position="inside">
|
<xpath expr="." position="inside">
|
||||||
|
<link rel="stylesheet" href="/document_url/static/src/css/url.css" type="text/css"/>
|
||||||
<script type="text/javascript" src="/document_url/static/src/js/url.js"></script>
|
<script type="text/javascript" src="/document_url/static/src/js/url.js"></script>
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
@ -34,6 +34,5 @@
|
|||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</openerp>
|
</odoo>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# © 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com)
|
# © 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com)
|
||||||
# Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
|
# Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
|
||||||
# © 2016 ACSONE SA/NV (<http://acsone.eu>)
|
# © 2016 ACSONE SA/NV (<http://acsone.eu>)
|
||||||
from openerp.osv import fields, orm
|
from odoo import models, fields, api, _
|
||||||
try:
|
try:
|
||||||
# Python 3
|
# Python 3
|
||||||
from urllib import parse as urlparse
|
from urllib import parse as urlparse
|
||||||
@ -10,33 +10,29 @@ except:
|
|||||||
from urlparse import urlparse
|
from urlparse import urlparse
|
||||||
|
|
||||||
|
|
||||||
class AddUrlWizard(orm.TransientModel):
|
class AddUrlWizard(models.TransientModel):
|
||||||
_name = 'ir.attachment.add_url'
|
_name = 'ir.attachment.add_url'
|
||||||
|
|
||||||
_columns = {
|
|
||||||
'name': fields.char('Name', required=True),
|
|
||||||
'url': fields.char('URL', required=True),
|
|
||||||
}
|
|
||||||
|
|
||||||
def action_add_url(self, cr, uid, ids, context=None):
|
name = fields.Char('Name', required=True)
|
||||||
|
url = fields.Char('URL', required=True)
|
||||||
|
|
||||||
|
@api.one
|
||||||
|
@api.multi
|
||||||
|
def action_add_url(self):
|
||||||
"""Adds the URL with the given name as an ir.attachment record."""
|
"""Adds the URL with the given name as an ir.attachment record."""
|
||||||
if context is None:
|
|
||||||
context = {}
|
for form in self:
|
||||||
if not context.get('active_model'):
|
|
||||||
return
|
|
||||||
attachment_obj = self.pool['ir.attachment']
|
|
||||||
for form in self.browse(cr, uid, ids, context=context):
|
|
||||||
url = urlparse(form.url)
|
url = urlparse(form.url)
|
||||||
if not url.scheme:
|
if not url.scheme:
|
||||||
url = urlparse('%s%s' % ('http://', form.url))
|
url = urlparse('%s%s' % ('http://', form.url))
|
||||||
for active_id in context.get('active_ids', []):
|
for active_id in self._context.get('active_ids', []):
|
||||||
attachment = {
|
attachment = {
|
||||||
'name': form.name,
|
'name': form.name,
|
||||||
'type': 'url',
|
'type': 'url',
|
||||||
'url': url.geturl(),
|
'url': url.geturl(),
|
||||||
'user_id': uid,
|
|
||||||
'res_id': active_id,
|
'res_id': active_id,
|
||||||
'res_model': context['active_model'],
|
'res_model': self._context.get('active_model')
|
||||||
}
|
}
|
||||||
attachment_obj.create(cr, uid, attachment, context=context)
|
self.env['ir.attachment'].create(attachment)
|
||||||
return {'type': 'ir.actions.act_close_wizard_and_reload_view'}
|
return {'type': 'ir.actions.act_close_wizard_and_reload_view'}
|
Loading…
Reference in New Issue
Block a user