[FIX] Create new records as a bunch of empty (false) fields, otherwise Bad Things Happen ~/projects/tiny/web/current

namely, if the list view fields have e.g. attributes associated, the
computation of the domains blow up

also, always create an editor in the listview (if the editable
listview module has been installed), avoids blowing up 'safety' calls
to #ensureSaved. An alternative would be to fix #ensureSaved not to
blow up if there's no editor, but that means third parties which
*know* there may be an editor in the list view can't easily hook up to
it.

Things will have to change anyway as currently toggling a list view
from not-editable to editable after on_loaded has been called will not
work correctly (it won't start the editor), which is shitty.

bzr revid: xmo@openerp.com-20120705143721-4fiz64k7fka4052k
This commit is contained in:
Xavier Morel 2012-07-05 16:37:21 +02:00
parent d968398d15
commit ee20d56357
1 changed files with 8 additions and 3 deletions

View File

@ -12,6 +12,8 @@ openerp.web.list_editable = function (instance) {
var self = this;
this._super.apply(this, arguments);
this.editor = new instance.web.list.Editor(this);
$(this.groups).bind({
'edit': function (e, id, dataset) {
self.do_edit(dataset.index, id, dataset);
@ -80,8 +82,6 @@ openerp.web.list_editable = function (instance) {
this.options.editable = ! this.options.read_only && (data.arch.attrs.editable || this.options.editable);
var result = this._super(data, grouped);
if (this.options.editable) {
this.editor = new instance.web.list.Editor(this);
var editor_ready = this.editor.prependTo(this.$element)
.then(this.proxy('setupEvents'));
@ -119,7 +119,12 @@ openerp.web.list_editable = function (instance) {
startEdition: function (record) {
var self = this;
if (!record) {
record = new instance.web.list.Record();
var attrs = {};
_(this.columns).chain()
.filter(function (x) { return x.tag === 'field'})
.pluck('name')
.each(function (field) { attrs[field] = false; });
record = new instance.web.list.Record(attrs);
this.records.add(record, {
at: this.isPrependOnCreate() ? 0 : null});
}