[IMP] fix import
authorAntony Lesuisse <al@openerp.com>
Mon, 24 Oct 2011 22:40:55 +0000 (00:40 +0200)
committerAntony Lesuisse <al@openerp.com>
Mon, 24 Oct 2011 22:40:55 +0000 (00:40 +0200)
bzr revid: al@openerp.com-20111024224055-6t5kamjz92h81fb6

addons/edi/static/src/js/edi.js

index 21710ea..acf32de 100644 (file)
@@ -58,45 +58,22 @@ openerp.edi.EdiImport = openerp.web.Widget.extend({
         this.template = "EdiEmpty";
     },
     start: function() {
-        console.log("import valid",this.url);
-        this.session.on_session_valid.add_last(self.do_import);
+        this.session.on_session_valid.add_last(this.do_import);
+        // TODO if session invalid ask for login
         this.session.start();
     },
     do_import: function() {
-        console.log("import okokoko",this.url);
         this.rpc('/edi/import_edi_url', {"url": this.url}, this.on_imported, this.on_imported_error);
     },
-    on_imported: function(response){
-        $('<div>Import successful, click Ok to see the new document</div>').dialog({
-        modal: true,
-        title: 'Successful',
-        buttons: {
-            Ok: function() {
-                $(this).dialog("close");
-//                var action = {
-//                    "res_model": response[0][0],
-//                    "res_id": parseInt(response[0][1], 10),
-//                    "views":[[false,"form"]],
-//                    "type":"ir.actions.act_window",
-//                    "view_type":"form",
-//                    "view_mode":"form"
-//                }
-//                action.flags = {
-//                    search_view: false,
-//                    sidebar : false,
-//                    views_switcher : false,
-//                    action_buttons : false,
-//                    pager: false
-//                }
-//                var action_manager = new openerp.web.ActionManager(self);
-//                action_manager.appendTo($("#oe_app"));
-//                action_manager.start();
-//                action_manager.do_action(action);
-               }
-            }
-        });
+    on_imported: function(response) {
+        console.log("responde from import",response);
+        // response is null when exception
+        // model: response[0][0],
+        // id: parseInt(response[0][1], 10),
+        window.location = "/web/webclient/home?debug=1#model=MODEL&id=ID";
     },
     on_imported_error: function(response){
+        var self = this;
         $(openerp.web.qweb.render("DialogWarning", "Sorry, Import is not successful.")).dialog({
             modal: true,
             buttons: {