[IMP] Read-only many2many implemented.

bzr revid: nicolas.vanhoren@openerp.com-20110426112413-nfoozpnol8zbli26
This commit is contained in:
niv-openerp
2011-04-26 13:24:13 +02:00
parent 5e2cda5a0c
commit 2cfc487ccd
2 changed files with 31 additions and 6 deletions
+9
View File
@@ -183,6 +183,15 @@ openerp.base.DataSetSearch = openerp.base.DataSet.extend({
openerp.base.DataSetRelational = openerp.base.DataSet.extend( /** @lends openerp.base.DataSet# */{
});
openerp.base.DataSetMany2Many = openerp.base.DataSetSearch.extend({
/* should extend DataSetStatic instead, but list view still does not support it
*/
unlink: function(ids) {
// just do nothing
},
});
};
// vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax:
+22 -6
View File
@@ -900,20 +900,36 @@ openerp.base.form.FieldMany2Many = openerp.base.form.Field.extend({
},
start: function() {
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.dataset = new openerp.base.DataSetMany2Many(this.session, this.field.relation);
this.list_view = new openerp.base.form.Many2ManyListView(undefined, this.view.session,
this.list_id, this.dataset, false, {'selected': false, 'addable': null, 'deletable': false});
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();
// this is not correct behavior, need to change once list view can work with
// static datasets
this.dataset.domain = [["id","in",value]];
/*this.dataset.ids = value;
this.dataset.count = value.length;*/
this.list_view.do_reload();
}
}
});
openerp.base.form.Many2ManyListView = openerp.base.ListView.extend({
do_delete: function (e) {
/*
e.stopImmediatePropagation();
var ids = [this.rows[$(e.currentTarget).closest('tr').prevAll().length].data.id.value];
this.dataset.ids = _.without.apply(null, [this.dataset.ids].concat(ids));
this.dataset.count = this.dataset.ids.length;
// there may be a faster way
this.do_reload();
*/
}
});
openerp.base.form.FieldReference = openerp.base.form.Field.extend({
init: function(view, node) {
this._super(view, node);