[MERGE] ask for login when importing edi file if needed

bzr revid: al@openerp.com-20120131210131-k1141eoel0l3b26c
This commit is contained in:
Antony Lesuisse 2012-01-31 22:01:31 +01:00
commit f2aea7dfc2
2 changed files with 34 additions and 17 deletions

View File

@ -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:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -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'));
});
}