1 openerp.edi = function(instance) {
2 var _t = instance.web._t;
6 instance.edi.EdiImport = instance.web.Widget.extend({
8 init: function(parent,url) {
13 if (!this.session.session_is_valid()) {
14 instance.redirect('/web/login?redir=' + encodeURIComponent(window.location));
20 show_import: function() {
21 this.destroy_content();
25 destroy_content: function() {
26 _.each(_.clone(this.getChildren()), function(el) {
29 this.$el.children().remove();
32 do_import: function() {
33 this.rpc('/edi/import_edi_url', {url: this.url}).done(this.on_imported).fail(this.on_imported_error);
35 on_imported: function(response) {
36 if ('action' in response) {
37 this.rpc("/web/session/save_session_action", {the_action: response.action}).done(function(key) {
38 window.location = "/#sa="+encodeURIComponent(key);
44 title: 'Import Successful!',
47 $(this).dialog("close");
48 window.location = "/";
51 }).html(_t('The document has been successfully imported!'));
54 on_imported_error: function(response){
56 var msg = _t("Sorry, the document could not be imported.");
57 if (response.data.message) {
58 msg += "\n " + _t("Reason:") + response.data.message;
60 var params = {error: response, message: msg};
61 $(instance.web.qweb.render("CrashManager.warning", params)).dialog({
62 title: _t("Document Import Notification"),
65 Ok: function() { $(this).dialog("close"); }
71 instance.edi.edi_import = function (url) {
72 instance.session.session_bind().done(function () {
73 new instance.edi.EdiImport(null,url).appendTo($("body").addClass('openerp'));
78 // vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax: