diff --git a/document_url/__openerp__.py b/document_url/__openerp__.py index 49659775..1ff4fb8e 100644 --- a/document_url/__openerp__.py +++ b/document_url/__openerp__.py @@ -4,11 +4,11 @@ # © 2016 ACSONE SA/NV () { 'name': 'URL attachment', - 'version': '9.0.1.0.0', + 'version': '9.0.2.0.0', 'category': 'Tools', 'author': "Tecnativa," "Odoo Community Association (OCA)", - 'website': 'http://www.serviciosbaeza.com', + 'website': 'http://www.tecnativa.com', 'license': 'AGPL-3', 'depends': [ 'document', diff --git a/document_url/static/src/js/url.js b/document_url/static/src/js/url.js index 0eaefa47..050f8a85 100644 --- a/document_url/static/src/js/url.js +++ b/document_url/static/src/js/url.js @@ -1,56 +1,31 @@ /* © 2014 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com) * Pedro M. Baeza * © 2016 ACSONE SA/NV () + * Copyright 2016 Jairo Llopis * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). */ odoo.define('document_url', function(require) { - - var core = require('web.core'); + "use strict"; var Sidebar = require('web.Sidebar'); - var ActionManager = require('web.ActionManager'); - - var _t = core._t, - QWeb = core.qweb; Sidebar.include({ - redraw: function() { - var self = this; - this._super.apply(this, arguments); - self.$el.find("a[href]").attr('target', '_blank'); - self.$el.find('.oe_sidebar_add_attachment, .o_sidebar_add_attachment').after(QWeb.render('AddUrlDocumentItem', {widget: self})) - self.$el.find('.oe_sidebar_add_url').on('click', function (e) { - self.on_url_doc(); - }); + init: function (parent, options) { + var result = this._super(parent, options); + this.items.url_doc = [ + { + action: { + id: "document_url.action_ir_attachment_add_url", + }, + }, + ]; + return result; }, - on_url_doc: function() { - var self = this; - var view = self.getParent(); - var ids = ( view.fields_view.type != "form" )? view.groups.get_selection().ids : [ view.datarecord.id ]; - if( !_.isEmpty(ids) ){ - view.sidebar_eval_context().done(function (context) { - self.rpc("/web/action/load", { action_id: "document_url.action_ir_attachment_add_url" }).done(function(result) { - self.getParent().do_action(result, { - additional_context: { - 'active_ids': ids, - 'active_id': [ids[0]], - 'active_model': view.dataset.model, - }, - }); - }); - }); - } + + redraw: function () { + var result = this._super(); + // Open URLs in a different browser tab + this.$el.find("a[href]").attr('target', '_blank'); + return result; }, }); - - ActionManager = ActionManager.include({ - ir_actions_act_close_wizard_and_reload_view: function (action, options) { - if (!this.dialog) { - options.on_close(); - } - this.dialog_stop(); - this.inner_widget.views[this.inner_widget.active_view.type].controller.reload(); - return $.when(); - }, - }); - }); diff --git a/document_url/static/src/xml/url.xml b/document_url/static/src/xml/url.xml index f55fbc38..f3be8b8d 100644 --- a/document_url/static/src/xml/url.xml +++ b/document_url/static/src/xml/url.xml @@ -1,8 +1,14 @@ - - -
  • - Add URL... -
  • -
    + + + + + +
  • + Add URL... +
  • +
    +
    diff --git a/document_url/wizard/document_url.py b/document_url/wizard/document_url.py index 8b7b21eb..95c4f48a 100644 --- a/document_url/wizard/document_url.py +++ b/document_url/wizard/document_url.py @@ -39,4 +39,5 @@ class AddUrlWizard(orm.TransientModel): 'res_model': context['active_model'], } attachment_obj.create(cr, uid, attachment, context=context) - return {'type': 'ir.actions.act_close_wizard_and_reload_view'} + # Close client dialog + return False