[imp] make related work in form view and m2o

bzr revid: nicolas.vanhoren@openerp.com-20110826131319-qzyrv7ypmv313jgj
This commit is contained in:
niv-openerp 2011-08-26 15:13:19 +02:00
commit a21f3c6686
3 changed files with 28 additions and 9 deletions

View 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] : [];
}
});
@ -1558,12 +1562,11 @@ openerp.base.form.FieldMany2One = openerp.base.form.Field.extend({
action_id: related[2].id,
context: {
active_id: self.value[0],
active_ids: self.value[1],
active_ids: [self.value[0]],
active_model: self.field.relation
}
}, function(result) {
//TODO niv
debugger;
self.do_action(result.result);
});
}
});

View 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# */{
/**

View File

@ -376,8 +376,7 @@ openerp.base.Sidebar = openerp.base.Widget.extend({
this.sections = {};
},
start: function() {
var self = this;
this._super(this, arguments);
this._super(this);
this.$element.html(QWeb.render('Sidebar'));
this.$element.find(".toggle-sidebar").click(function(e) {
self.do_toggle();
@ -433,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;
});