diff options
| author | Xavier Morel <xmo@openerp.com> | 2012-11-12 16:05:26 +0100 |
|---|---|---|
| committer | Xavier Morel <xmo@openerp.com> | 2012-11-12 16:05:26 +0100 |
| commit | 06bcfd27fc6328828429fcd0e4a1033b10ff0277 (patch) | |
| tree | b2917764c0682ecd19aa8d622e62e30482162b11 /addons/web/static/src | |
| parent | d5996402a44d3dbad3287f0379a682a3a221316e (diff) | |
[FIX] editable listview @on_write handling in case of @colors
the onwrite handler created an "empty" record with no field value
whatsoever, which'd blow up in the py evaluator. As during creation
(edition of a record where all fields are empty) create a record where
all fields are set to ``false`` so rendering works correctly, and wait
for content refresh to get correct data.
Also added a test for @on_write
bzr revid: xmo@openerp.com-20121112150526-vrr66ms95qbuoped
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/view_list_editable.js | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js index 37ce8c4f8b4..f144b5485c7 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -173,6 +173,22 @@ openerp.web.list_editable = function (instance) { }); }, /** + * Builds a record with the provided id (``false`` for a creation), + * setting all columns with ``false`` value so code which relies on + * having an actual value behaves correctly + * + * @param {*} id + * @return {instance.web.list.Record} + */ + make_empty_record: function (id) { + var attrs = {id: id}; + _(this.columns).chain() + .filter(function (x) { return x.tag === 'field'}) + .pluck('name') + .each(function (field) { attrs[field] = false; }); + return new instance.web.list.Record(attrs); + }, + /** * Set up the edition of a record of the list view "inline" * * @param {instance.web.list.Record} [record] record to edit, leave empty to create a new record @@ -186,12 +202,7 @@ openerp.web.list_editable = function (instance) { if (record) { item = record.attributes; } else { - var attrs = {id: false}; - _(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); + record = this.make_empty_record(false); this.records.add(record, { at: this.prepends_on_create() ? 0 : null}); } @@ -391,7 +402,7 @@ openerp.web.list_editable = function (instance) { if (!record) { // insert after the source record var index = this.records.indexOf(source_record) + 1; - record = new instance.web.list.Record({id: id}); + record = this.make_empty_record(id); this.records.add(record, {at: index}); this.dataset.ids.splice(index, 0, id); } |
