[IMP] Some code about many2many widgets.
bzr revid: nicolas.vanhoren@openerp.com-20110422155452-9lth3lrm8pwf9c2r
This commit is contained in:
parent
ceb524e337
commit
0ae1e8f2b9
|
@ -896,6 +896,22 @@ openerp.base.form.FieldMany2Many = openerp.base.form.Field.extend({
|
|||
init: function(view, node) {
|
||||
this._super(view, node);
|
||||
this.template = "FieldMany2Many";
|
||||
this.list_id = _.uniqueId("many2many");
|
||||
},
|
||||
start: function() {
|
||||
debugger;
|
||||
this._super.apply(this, arguments);
|
||||
this.dataset = new openerp.base.DataSetSearch(this.session, this.field.relation);
|
||||
this.list_view = new openerp.base.ListView(undefined, this.view.session,
|
||||
this.list_id, this.dataset, false, undefined);
|
||||
this.list_view.start();
|
||||
},
|
||||
set_value: function(value) {
|
||||
if (value != false) {
|
||||
this.dataset.ids = value;
|
||||
this.dataset.count = value.length;
|
||||
this.list_view.do_update();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ openerp.base.ListView = openerp.base.Controller.extend(
|
|||
return this.rpc("/base/listview/load", {
|
||||
model: this.model,
|
||||
view_id: this.view_id,
|
||||
toolbar: !!this.view_manager.sidebar
|
||||
toolbar: this.view_manager ? !!this.view_manager.sidebar : false
|
||||
}, this.on_loaded);
|
||||
},
|
||||
/**
|
||||
|
@ -168,7 +168,7 @@ openerp.base.ListView = openerp.base.Controller.extend(
|
|||
'tr', 'click', this.on_select_row);
|
||||
|
||||
// sidebar stuff
|
||||
if (this.view_manager.sidebar) {
|
||||
if (this.view_manager && this.view_manager.sidebar) {
|
||||
this.view_manager.sidebar.set_toolbar(data.fields_view.toolbar);
|
||||
}
|
||||
},
|
||||
|
@ -262,7 +262,9 @@ openerp.base.ListView = openerp.base.Controller.extend(
|
|||
view = view || 'form';
|
||||
this.dataset.index = index;
|
||||
_.delay(_.bind(function () {
|
||||
this.view_manager.on_mode_switch(view);
|
||||
if(this.view_manager) {
|
||||
this.view_manager.on_mode_switch(view);
|
||||
}
|
||||
}, this));
|
||||
},
|
||||
/**
|
||||
|
|
|
@ -353,6 +353,7 @@
|
|||
<t t-name="FieldMany2Many">
|
||||
<div style="background: #ccc; padding: 20px">
|
||||
Many2Many widget
|
||||
<div t-attr-id="widget.list_id"></div>
|
||||
</div>
|
||||
</t>
|
||||
<t t-name="FieldReference">
|
||||
|
|
Loading…
Reference in New Issue