diff options
| author | Christophe Matthieu <chm@odoo.com> | 2017-03-08 15:49:52 +0100 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-04-11 19:44:38 +0200 |
| commit | 454b21538917558cfb71c0b98bf49a1d8efa7eee (patch) | |
| tree | 02b148d7ba24e551530ba43d427aba57b8503402 /addons/web/static/src/js/views/basic/basic_renderer.js | |
| parent | 53d8d38f93d59ae5ca23046d20d1b33bfd1e8838 (diff) | |
[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
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_renderer.js')
| -rw-r--r-- | addons/web/static/src/js/views/basic/basic_renderer.js | 16 |
1 files changed, 10 insertions, 6 deletions
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 |
