openerp.edi = function(instance) { var _t = instance.web._t; instance.edi = {} instance.edi.EdiImport = instance.web.Widget.extend({ init: function(parent,url) { this._super(); this.url = url; }, start: function() { if (!this.session.session_is_valid()) { this.show_login(); this.session.on_session_valid.add({ callback: this.proxy('show_import'), unique: true, }); } else { this.show_import(); } }, show_import: function() { this.destroy_content(); this.do_import(); }, show_login: function() { this.destroy_content(); this.login = new instance.web.Login(this); this.login.appendTo(this.$el); }, destroy_content: function() { _.each(_.clone(this.getChildren()), function(el) { el.destroy(); }); this.$el.children().remove(); }, do_import: function() { this.rpc('/edi/import_edi_url', {url: this.url}).done(this.on_imported).fail(this.on_imported_error); }, on_imported: function(response) { if ('action' in response) { this.rpc("/web/session/save_session_action", {the_action: response.action}).done(function(key) { window.location = "/#sa="+encodeURIComponent(key); }); } else { $('