summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Lesuisse <al@openerp.com>2012-01-31 22:01:31 +0100
committerAntony Lesuisse <al@openerp.com>2012-01-31 22:01:31 +0100
commitf2aea7dfc2c21bc88ef75d1c7bd27c8149d604ab (patch)
tree3beba6d5e9adcd7851318ab97179fd1d3f88d3d1
parent60c47d9f98793d5591807722dc1352ee7fe94861 (diff)
parentdb1ffb561b704d76a6ee80faf94fbce906df82e5 (diff)
[MERGE] ask for login when importing edi file if needed
bzr revid: al@openerp.com-20120131210131-k1141eoel0l3b26c
-rw-r--r--addons/edi/models/edi.py6
-rw-r--r--addons/edi/static/src/js/edi.js45
2 files changed, 34 insertions, 17 deletions
diff --git a/addons/edi/models/edi.py b/addons/edi/models/edi.py
index c573115618e..589922ff178 100644
--- a/addons/edi/models/edi.py
+++ b/addons/edi/models/edi.py
@@ -2,7 +2,7 @@
##############################################################################
#
# OpenERP, Open Source Business Applications
-# Copyright (c) 2011 OpenERP S.A. <http://openerp.com>
+# Copyright (c) 2011-2012 OpenERP S.A. <http://openerp.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@@ -37,7 +37,7 @@ from tools.translate import _
from tools.safe_eval import safe_eval as eval
EXTERNAL_ID_PATTERN = re.compile(r'^([^.:]+)(?::([^.]+))?\.(\S+)$')
-EDI_VIEW_WEB_URL = '%s/edi/view?debug=1&db=%s&token=%s'
+EDI_VIEW_WEB_URL = '%s/edi/view?db=%s&token=%s'
EDI_PROTOCOL_VERSION = 1 # arbitrary ever-increasing version number
EDI_GENERATOR = 'OpenERP ' + release.major_version
EDI_GENERATOR_VERSION = release.version_info
@@ -682,4 +682,4 @@ class EDIMixin(object):
return record_id
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/edi/static/src/js/edi.js b/addons/edi/static/src/js/edi.js
index 5493077e831..0f59768bc4e 100644
--- a/addons/edi/static/src/js/edi.js
+++ b/addons/edi/static/src/js/edi.js
@@ -109,7 +109,7 @@ openerp.edi.EdiView = openerp.web.OldWidget.extend({
openerp.edi.edi_view = function (db, token) {
openerp.connection.bind().then(function () {
- new openerp.edi.EdiView(null,db,token).appendTo($("body"));
+ new openerp.edi.EdiView(null,db,token).appendTo($("body").addClass('openerp'));
});
}
@@ -117,27 +117,44 @@ openerp.edi.EdiImport = openerp.web.OldWidget.extend({
init: function(parent,url) {
this._super();
this.url = url;
- var params = {};
-
- this.template = "EdiImport";
- this.session = openerp.connection;
- this.login = new openerp.web.Login(this);
- this.header = new openerp.web.Header(this);
},
start: function() {
- // TODO fix by explicitly asking login if needed
- //this.session.on_session_invalid.add_last(this.do_ask_login);
- this.header.appendTo($("#oe_header"));
- this.login.appendTo($('#oe_login'));
+ 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 openerp.web.Login(this);
+ this.login.appendTo(this.$element);
+ },
+
+ destroy_content: function() {
+ _.each(_.clone(this.widget_children), function(el) {
+ el.stop();
+ });
+ this.$element.children().remove();
+ },
+
do_import: function() {
this.rpc('/edi/import_edi_url', {url: this.url}, this.on_imported, this.on_imported_error);
},
on_imported: function(response) {
if ('action' in response) {
this.rpc("/web/session/save_session_action", {the_action: response.action}, function(key) {
- window.location = "/web/webclient/home?debug=1&s_action="+encodeURIComponent(key);
+ window.location = "/web/webclient/home#sa="+encodeURIComponent(key);
});
}
else {
@@ -147,7 +164,7 @@ openerp.edi.EdiImport = openerp.web.OldWidget.extend({
buttons: {
Ok: function() {
$(this).dialog("close");
- window.location = "/web/webclient/home";
+ window.location = "/";
}
}
}).html('The document has been successfully imported!');
@@ -172,7 +189,7 @@ openerp.edi.EdiImport = openerp.web.OldWidget.extend({
openerp.edi.edi_import = function (url) {
openerp.connection.bind().then(function () {
- new openerp.edi.EdiImport(null,url).appendTo($("body"));
+ new openerp.edi.EdiImport(null,url).appendTo($("body").addClass('openerp'));
});
}