From 454b21538917558cfb71c0b98bf49a1d8efa7eee Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Wed, 8 Mar 2017 15:49:52 +0100 Subject: [FIX] web: properly transfer field properties Before this commit, the field properties (attrs, fieldNames, fields) were not correctly given to sub views in many case expected: * use widget many2many on one2many field * create record when click on save in formDialog * do not send create command to the server * use the fields defined in the field node (instead of tree view fields) * use the fieldNames instead of the record to get field values --- addons/web/static/src/js/views/basic/basic_renderer.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'addons/web/static/src/js/views/basic/basic_renderer.js') diff --git a/addons/web/static/src/js/views/basic/basic_renderer.js b/addons/web/static/src/js/views/basic/basic_renderer.js index 22ec34f714b..e581b222417 100644 --- a/addons/web/static/src/js/views/basic/basic_renderer.js +++ b/addons/web/static/src/js/views/basic/basic_renderer.js @@ -63,24 +63,28 @@ return AbstractRenderer.extend({ * @returns {Object} */ _getFieldValues: function (record) { - return _.mapObject(record.data, function (value, name) { + var result = {}; + _.each(record.fieldNames, function (name) { var field = record.fields[name]; + var value = record.data[name]; + result[name] = value; if (field.type === 'many2one') { - return value.data ? value.data.id || false : false; + result[name] = value.data ? value.data.id || false : false; } if (field.type === 'one2many' || field.type === 'many2many') { if (value) { - return _.pluck(value.data, 'res_id'); + result[name] = _.pluck(value.data, 'res_id'); } else { - return []; + result[name] = []; } } if (field.type === 'boolean') { // we want an explicit false value, not null if it is unset - return value || false; + result[name] = value || false; } - return value; }); + result.id = record.data.id; + return result; }, /** * Render the view -- cgit v1.2.3