diff --git a/document_url/__manifest__.py b/document_url/__manifest__.py index 376edae6..1a0bd562 100644 --- a/document_url/__manifest__.py +++ b/document_url/__manifest__.py @@ -1,23 +1,15 @@ # Copyright 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com) # Pedro M. Baeza # Copyright 2016 ACSONE SA/NV () +# Copyright 2020 Tecnativa - Manuel Calero { - 'name': 'URL attachment', - 'version': '12.0.1.0.0', - 'category': 'Tools', - 'author': "Tecnativa," - "Odoo Community Association (OCA)", - 'website': 'https://github.com/OCA/knowledge', - 'license': 'AGPL-3', - 'depends': [ - 'document', - ], - 'data': [ - 'view/document_url_view.xml', - 'security/ir.model.access.csv', - ], - 'qweb': [ - 'static/src/xml/url.xml', - ], - 'installable': True, + "name": "URL attachment", + "version": "13.0.1.0.0", + "category": "Tools", + "author": "Tecnativa," "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/knowledge", + "license": "AGPL-3", + "data": ["view/document_url_view.xml", "security/ir.model.access.csv"], + "qweb": ["static/src/xml/url.xml"], + "installable": True, } diff --git a/document_url/readme/CONTRIBUTORS.rst b/document_url/readme/CONTRIBUTORS.rst index f309e3c0..c3458d40 100644 --- a/document_url/readme/CONTRIBUTORS.rst +++ b/document_url/readme/CONTRIBUTORS.rst @@ -3,3 +3,4 @@ * Pedro M. Baeza * Ernesto Tejeda + * Manuel Calero diff --git a/document_url/static/description/index.html b/document_url/static/description/index.html index 93012317..09a6ef0b 100644 --- a/document_url/static/description/index.html +++ b/document_url/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/knowledge Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/knowledge Translate me on Weblate Try me on Runbot

Module that allows to attach an URL as a document.

Table of contents

@@ -399,7 +399,7 @@ the object.

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -428,7 +428,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

-

This module is part of the OCA/knowledge project on GitHub.

+

This module is part of the OCA/knowledge project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/document_url/static/src/js/url.js b/document_url/static/src/js/url.js index 3a6b1ece..329c9a16 100644 --- a/document_url/static/src/js/url.js +++ b/document_url/static/src/js/url.js @@ -2,6 +2,7 @@ * Pedro M. Baeza * Copyright 2016 ACSONE SA/NV () * Copyright 2019 Tecnativa - Ernesto Tejeda + * Copyright 2020 Tecnativa - Manuel Calero * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). */ odoo.define('document_url', function (require) { @@ -13,13 +14,8 @@ odoo.define('document_url', function (require) { events: _.extend(AttachmentBox.prototype.events, { "click span.o_add_url_button": "_onAddUrl", }), - /** - * Opens wizard to add an URL attachment to the current record - * - * @private - * @param {MouseEvent} ev - */ - _onAddUrl: function (ev) { + _onAddUrl: function () { + // Opens wizard to add an URL attachment to the current record this.do_action('document_url.action_ir_attachment_add_url', { additional_context: { 'active_id': this.currentResID, @@ -29,11 +25,8 @@ odoo.define('document_url', function (require) { on_close: this._onAddedUrl.bind(this), }); }, - /** - * @private - */ _onAddedUrl: function () { this.trigger_up('reload_attachment_box'); - } + }, }); }); diff --git a/document_url/tests/test_document_url.py b/document_url/tests/test_document_url.py index be262c3c..8f3b5cc7 100644 --- a/document_url/tests/test_document_url.py +++ b/document_url/tests/test_document_url.py @@ -6,25 +6,24 @@ from odoo.tests import common class TestDocumentUrl(common.TransactionCase): def setUp(self): super(TestDocumentUrl, self).setUp() - wizard_add_url = self.env['ir.attachment.add_url'] + wizard_add_url = self.env["ir.attachment.add_url"] ctx = { - 'active_model': 'res.users', - 'active_id': self.env.ref('base.user_demo').id, - 'active_ids': [self.env.ref('base.user_demo').id] + "active_model": "res.users", + "active_id": self.env.ref("base.user_demo").id, + "active_ids": [self.env.ref("base.user_demo").id], } - self.wizard_add_url = wizard_add_url.with_context(ctx).create({ - 'name': 'Demo User (Website)', - 'url': 'http://www.odoodemouser.com' - }) + self.wizard_add_url = wizard_add_url.with_context(ctx).create( + {"name": "Demo User (Website)", "url": "http://www.odoodemouser.com"} + ) def test_add_url_attachment(self): self.wizard_add_url.action_add_url() domain = [ - ('type', '=', 'url'), - ('name', '=', 'Demo User (Website)'), - ('url', '=', 'http://www.odoodemouser.com'), - ('res_model', '=', 'res.users'), - ('res_id', '=', self.env.ref('base.user_demo').id) + ("type", "=", "url"), + ("name", "=", "Demo User (Website)"), + ("url", "=", "http://www.odoodemouser.com"), + ("res_model", "=", "res.users"), + ("res_id", "=", self.env.ref("base.user_demo").id), ] - attachment_added_count = self.env['ir.attachment'].search_count(domain) + attachment_added_count = self.env["ir.attachment"].search_count(domain) self.assertEqual(attachment_added_count, 1) diff --git a/document_url/wizard/document_url.py b/document_url/wizard/document_url.py index 717f70a5..24f05ff3 100644 --- a/document_url/wizard/document_url.py +++ b/document_url/wizard/document_url.py @@ -1,33 +1,34 @@ # Copyright 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com) # Pedro M. Baeza # Copyright 2016 ACSONE SA/NV () -from odoo import fields, models from urllib import parse +from odoo import fields, models + class AddUrlWizard(models.Model): - _name = 'ir.attachment.add_url' - _description = 'Wizard to add URL attachment' + _name = "ir.attachment.add_url" + _description = "Wizard to add URL attachment" - name = fields.Char('Name', required=True) - url = fields.Char('URL', required=True) + name = fields.Char("Name", required=True) + url = fields.Char("URL", required=True) def action_add_url(self): """Adds the URL with the given name as an ir.attachment record.""" - if not self.env.context.get('active_model'): + if not self.env.context.get("active_model"): return - attachment_obj = self.env['ir.attachment'] + attachment_obj = self.env["ir.attachment"] for form in self: url = parse.urlparse(form.url) if not url.scheme: - url = parse.urlparse('%s%s' % ('http://', form.url)) - for active_id in self.env.context.get('active_ids', []): + url = parse.urlparse("{}{}".format("http://", form.url)) + for active_id in self.env.context.get("active_ids", []): attachment = { - 'name': form.name, - 'type': 'url', - 'url': url.geturl(), - 'res_id': active_id, - 'res_model': self.env.context['active_model'], + "name": form.name, + "type": "url", + "url": url.geturl(), + "res_id": active_id, + "res_model": self.env.context["active_model"], } attachment_obj.create(attachment) - return {'type': 'ir.actions.act_window_close'} + return {"type": "ir.actions.act_window_close"}