From f1040fbd3f3830adc278022bdd8f43f72e00c9ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s?= Date: Tue, 15 Nov 2016 17:16:40 +0000 Subject: [PATCH] [MIG]Port v10 --- document_url/README.rst | 4 +++- document_url/__manifest__.py | 2 +- document_url/static/src/css/url.css | 3 +++ document_url/static/src/xml/url.xml | 2 +- document_url/view/document_url_view.xml | 7 +++--- document_url/wizard/document_url.py | 32 +++++++++++-------------- 6 files changed, 25 insertions(+), 25 deletions(-) create mode 100644 document_url/static/src/css/url.css diff --git a/document_url/README.rst b/document_url/README.rst index 0766dd80..91b4afe0 100644 --- a/document_url/README.rst +++ b/document_url/README.rst @@ -40,7 +40,9 @@ Contributors ------------ * Jonathan Nemry -* Pedro M. Baeza +* Nicolás Ramos +* Antonio Cánovas Maintainer ---------- diff --git a/document_url/__manifest__.py b/document_url/__manifest__.py index 2d4e0a07..49659775 100644 --- a/document_url/__manifest__.py +++ b/document_url/__manifest__.py @@ -19,5 +19,5 @@ 'qweb': [ 'static/src/xml/url.xml', ], - 'installable': False, + 'installable': True, } diff --git a/document_url/static/src/css/url.css b/document_url/static/src/css/url.css new file mode 100644 index 00000000..89786c07 --- /dev/null +++ b/document_url/static/src/css/url.css @@ -0,0 +1,3 @@ +-.oe_url_attachment{ + - padding: 3px 20px; + -} diff --git a/document_url/static/src/xml/url.xml b/document_url/static/src/xml/url.xml index f55fbc38..57e0e301 100644 --- a/document_url/static/src/xml/url.xml +++ b/document_url/static/src/xml/url.xml @@ -2,7 +2,7 @@
  • - Add URL... + Add URL...
  • diff --git a/document_url/view/document_url_view.xml b/document_url/view/document_url_view.xml index e8bd2c10..f7fee40d 100644 --- a/document_url/view/document_url_view.xml +++ b/document_url/view/document_url_view.xml @@ -1,9 +1,9 @@ - + - @@ -34,6 +34,5 @@ - - + diff --git a/document_url/wizard/document_url.py b/document_url/wizard/document_url.py index 8b7b21eb..821b8f85 100644 --- a/document_url/wizard/document_url.py +++ b/document_url/wizard/document_url.py @@ -2,7 +2,7 @@ # © 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com) # Pedro M. Baeza # © 2016 ACSONE SA/NV () -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) - return {'type': 'ir.actions.act_close_wizard_and_reload_view'} + self.env['ir.attachment'].create(attachment) + return {'type': 'ir.actions.act_close_wizard_and_reload_view'} \ No newline at end of file