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 e581b222417..7b57f16dd84 100644
--- a/addons/web/static/src/js/views/basic/basic_renderer.js
+++ b/addons/web/static/src/js/views/basic/basic_renderer.js
@@ -68,17 +68,20 @@ return AbstractRenderer.extend({
var field = record.fields[name];
var value = record.data[name];
result[name] = value;
- if (field.type === 'many2one') {
+ if (!value) {
+ return;
+ }
+ else if (field.type === 'many2one') {
result[name] = value.data ? value.data.id || false : false;
}
- if (field.type === 'one2many' || field.type === 'many2many') {
+ else if (field.type === 'one2many' || field.type === 'many2many') {
if (value) {
result[name] = _.pluck(value.data, 'res_id');
} else {
result[name] = [];
}
}
- if (field.type === 'boolean') {
+ else if (field.type === 'boolean') {
// we want an explicit false value, not null if it is unset
result[name] = value || false;
}
diff --git a/addons/web/static/src/js/views/basic/basic_view.js b/addons/web/static/src/js/views/basic/basic_view.js
index aea0b88dcf3..d8e41b99835 100644
--- a/addons/web/static/src/js/views/basic/basic_view.js
+++ b/addons/web/static/src/js/views/basic/basic_view.js
@@ -115,7 +115,13 @@ var BasicView = AbstractView.extend({
*/
_loadData: function () {
if (this.recordID) {
- return $.when(this.recordID);
+ var record = this.model.get(this.recordID);
+ var fieldNames = _.difference(record.fieldNames, Object.keys(record.data));
+ if (fieldNames.length && !this.model.isNew(record.id)) {
+ return this.model.reload(this.recordID, {fieldNames: fieldNames});
+ } else {
+ return $.when(this.recordID);
+ }
}
return this._super.apply(this, arguments);
},
diff --git a/addons/web/static/test/fields/relational_fields_tests.js b/addons/web/static/test/fields/relational_fields_tests.js
index dadb388d65b..ca8c984e54e 100644
--- a/addons/web/static/test/fields/relational_fields_tests.js
+++ b/addons/web/static/test/fields/relational_fields_tests.js
@@ -90,9 +90,9 @@ QUnit.module('relational_fields', {
display_name: { string: "Displayed name", type: "char" },
turtle_foo: {string: "Foo", type: "char", default: "My little Foo Value"},
turtle_bar: {string: "Bar", type: "boolean", default: true},
- turtle_int: {string: "int", type: "integer", sortable: true, required: true},
- turtle_qux: {string: "Qux", type: "float", digits: [16,1], required: true},
- turtle_trululu: {string: "Trululu", type: "many2one", relation: 'partner', required: true, default: 1},
+ turtle_int: {string: "int", type: "integer", sortable: true},
+ turtle_qux: {string: "Qux", type: "float", digits: [16,1], required: true, default: 1.5},
+ turtle_trululu: {string: "Trululu", type: "many2one", relation: 'partner'},
product_id: {string: "Product", type: "many2one", relation: 'product', required: true},
},
records: [{
@@ -1677,7 +1677,7 @@ QUnit.module('relational_fields', {
assert.strictEqual(form.$('.o_data_row').length, 3,
"sould have 3 records in one2many list");
- assert.strictEqual(form.$('.o_data_row').text(), "blip0.09yop0.0tototo0.050xphone",
+ assert.strictEqual(form.$('.o_data_row').text(), "blip1.59yop1.5tototo1.550xphone",
"sould display the record values in one2many list");
$('.o_form_button_save').click();
@@ -1705,6 +1705,7 @@ QUnit.module('relational_fields', {
'' +
'' +
'' +
+ '' +
'' +
'' +
'' +