mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-26 10:28:40 -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>
|
||||
* 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
|
||||
----------
|
||||
|
@ -19,5 +19,5 @@
|
||||
'qweb': [
|
||||
'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">
|
||||
<t t-name="AddUrlDocumentItem">
|
||||
<li class="oe_sidebar_add_url">
|
||||
<a class="oe_file_attachment">Add URL...</a>
|
||||
<span class="oe_url_attachment">Add URL...</span>
|
||||
</li>
|
||||
</t>
|
||||
</templates>
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<template id="assets_backend" name="google_drive assets" inherit_id="web.assets_backend">
|
||||
<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>
|
||||
</xpath>
|
||||
</template>
|
||||
@ -34,6 +34,5 @@
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
</odoo>
|
||||
|
@ -2,7 +2,7 @@
|
||||
# © 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com)
|
||||
# Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
|
||||
# © 2016 ACSONE SA/NV (<http://acsone.eu>)
|
||||
from openerp.osv import fields, orm
|
||||
from odoo import models, fields, api, _
|
||||
try:
|
||||
# Python 3
|
||||
from urllib import parse as urlparse
|
||||
@ -10,33 +10,29 @@ except:
|
||||
from urlparse import urlparse
|
||||
|
||||
|
||||
class AddUrlWizard(orm.TransientModel):
|
||||
class AddUrlWizard(models.TransientModel):
|
||||
_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."""
|
||||
if context is None:
|
||||
context = {}
|
||||
if not context.get('active_model'):
|
||||
return
|
||||
attachment_obj = self.pool['ir.attachment']
|
||||
for form in self.browse(cr, uid, ids, context=context):
|
||||
|
||||
for form in self:
|
||||
url = urlparse(form.url)
|
||||
if not url.scheme:
|
||||
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 = {
|
||||
'name': form.name,
|
||||
'type': 'url',
|
||||
'url': url.geturl(),
|
||||
'user_id': uid,
|
||||
'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'}
|
Loading…
Reference in New Issue
Block a user