2012-04-17 12:48:30 +00:00
|
|
|
openerp.web_tests = function (instance) {
|
|
|
|
instance.web.client_actions.add(
|
2011-09-20 12:28:20 +00:00
|
|
|
'buncha-forms', 'instance.web_tests.BunchaForms');
|
2012-04-17 12:48:30 +00:00
|
|
|
instance.web_tests = {};
|
|
|
|
instance.web_tests.BunchaForms = instance.web.OldWidget.extend({
|
2011-09-20 12:28:20 +00:00
|
|
|
init: function (parent) {
|
|
|
|
this._super(parent);
|
2012-04-17 12:48:30 +00:00
|
|
|
this.dataset = new instance.web.DataSetSearch(this, 'test.listview.relations');
|
|
|
|
this.form = new instance.web.FormView(this, this.dataset, false, {
|
2011-09-20 12:28:20 +00:00
|
|
|
action_buttons: false,
|
|
|
|
pager: false
|
|
|
|
});
|
2012-04-17 12:48:30 +00:00
|
|
|
this.form.registry = instance.web.form.readonly;
|
2011-09-20 12:28:20 +00:00
|
|
|
},
|
|
|
|
render: function () {
|
|
|
|
return '<div class="oe-bunchaforms"></div>';
|
|
|
|
},
|
|
|
|
start: function () {
|
|
|
|
$.when(
|
|
|
|
this.dataset.read_slice(),
|
|
|
|
this.form.appendTo(this.$element)).then(this.on_everything_loaded);
|
|
|
|
},
|
|
|
|
on_everything_loaded: function (slice) {
|
|
|
|
var records = slice[0].records;
|
|
|
|
if (!records.length) {
|
|
|
|
this.form.on_record_loaded({});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.form.on_record_loaded(records[0]);
|
|
|
|
_(records.slice(1)).each(function (record, index) {
|
|
|
|
this.dataset.index = index+1;
|
|
|
|
this.form.reposition($('<div>').appendTo(this.$element));
|
|
|
|
this.form.on_record_loaded(record);
|
|
|
|
}, this);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|