summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Simonis <chs@openerp.com>2012-01-13 12:21:21 +0100
committerChristophe Simonis <chs@openerp.com>2012-01-13 12:21:21 +0100
commitdb1ffb561b704d76a6ee80faf94fbce906df82e5 (patch)
treedd3d916b9ef6223ac3e4d342823361eb5d86419c
parentfb2e5f04c00d492b6edfab0c73b230ab6c0ef591 (diff)
[FIX] edi: ask login before import
bzr revid: chs@openerp.com-20120113112121-5tlnb2he9sw8cbe0
-rw-r--r--addons/edi/static/src/js/edi.js47
1 files changed, 33 insertions, 14 deletions
diff --git a/addons/edi/static/src/js/edi.js b/addons/edi/static/src/js/edi.js
index 352177156e1..d62a4c3b780 100644
--- a/addons/edi/static/src/js/edi.js
+++ b/addons/edi/static/src/js/edi.js
@@ -114,30 +114,49 @@ openerp.edi.edi_view = function (db, token) {
}
openerp.edi.EdiImport = openerp.web.Widget.extend({
- init: function(parent,url) {
- this._super();
- this.url = url;
- var params = {};
+ template: "EdiImport",
- this.template = "EdiImport";
- this.session = openerp.connection;
- this.login = new openerp.web.Login(this);
- this.header = new openerp.web.Header(this);
+ init: function(parent, url) {
+ this._super(parent);
+ this.url = url;
},
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 +166,7 @@ openerp.edi.EdiImport = openerp.web.Widget.extend({
buttons: {
Ok: function() {
$(this).dialog("close");
- window.location = "/web/webclient/home";
+ window.location = "/";
}
}
}).html('The document has been successfully imported!');