[imp] made related work from form view
authorniv-openerp <nicolas.vanhoren@openerp.com>
Fri, 26 Aug 2011 13:03:35 +0000 (15:03 +0200)
committerniv-openerp <nicolas.vanhoren@openerp.com>
Fri, 26 Aug 2011 13:03:35 +0000 (15:03 +0200)
bzr revid: nicolas.vanhoren@openerp.com-20110826130335-fjt0c5f7s7ug2jdl

addons/base/static/src/js/form.js
addons/base/static/src/js/list.js
addons/base/static/src/js/views.js

index 55bf743..212f487 100644 (file)
@@ -441,6 +441,10 @@ openerp.base.FormView = openerp.base.View.extend( /** @lends openerp.base.FormVi
             values[key] = val;
         });
         return values;
+    },
+    get_selected_ids: function() {
+        var id = this.dataset.ids[this.dataset.index];
+        return id ? [id] : [];
     }
 });
 
index a02b05b..5289cdb 100644 (file)
@@ -597,8 +597,11 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi
             $footer_cells.filter(_.sprintf('[data-field=%s]', column.id))
                 .html(openerp.base.format_cell(aggregation, column));
         });
+    },
+    get_selected_ids: function() {
+        //TODO niv: this is false
+        debugger;
     }
-    // TODO: implement reorder (drag and drop rows)
 });
 openerp.base.ListView.List = openerp.base.Class.extend( /** @lends openerp.base.ListView.List# */{
     /**
index ee55292..1e07c46 100644 (file)
@@ -432,9 +432,23 @@ openerp.base.Sidebar = openerp.base.Widget.extend({
                     item.callback();
                 }
                 if (item.action) {
-                    item.action.flags = item.action.flags || {};
-                    item.action.flags.new_window = true;
-                    self.do_action(item.action);
+                    var ids = self.widget_parent.get_selected_ids();
+                    if (ids.length == 0) {
+                        //TODO niv: maybe show a warning?
+                        return false;
+                    }
+                    self.rpc("/base/action/load", {
+                        action_id: item.action.id,
+                        context: {
+                            active_id: ids[0],
+                            active_ids: ids,
+                            active_model: self.widget_parent.dataset.model
+                        }
+                    }, function(result) {
+                        result.result.flags = result.result.flags || {};
+                        result.result.flags.new_window = true;
+                        self.do_action(result.result);
+                    });
                 }
                 return false;
             });