[FIX] web: don't delete the fields with value false on record creation
Before this commit, all the fields with value `false` on record creation were deleted from the given parameters for the `create` rpc. e.g. it was impossible to untick a checkbox in the settings, the `false` value was not saved in the created record.
This commit is contained in:
@@ -671,7 +671,6 @@ var BasicModel = AbstractModel.extend({
|
||||
if (method === 'create') {
|
||||
var fieldNames = record.getFieldNames();
|
||||
_.each(fieldNames, function (name) {
|
||||
changes[name] = changes[name] || record.data[name];
|
||||
if (changes[name] === null) {
|
||||
delete changes[name];
|
||||
}
|
||||
|
||||
@@ -3378,5 +3378,29 @@ QUnit.module('Views', {
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('create with false values', function (assert) {
|
||||
assert.expect(1);
|
||||
var form = createView({
|
||||
View: FormView,
|
||||
model: 'partner',
|
||||
data: this.data,
|
||||
arch: '<form string="Partners">' +
|
||||
'<group><field name="bar"/></group>' +
|
||||
'</form>',
|
||||
mockRPC: function (route, args) {
|
||||
if (args.method === 'create') {
|
||||
assert.strictEqual(args.args[0].bar, false,
|
||||
"the false value should be given as parameter");
|
||||
}
|
||||
return this._super(route, args);
|
||||
},
|
||||
debug: true,
|
||||
});
|
||||
|
||||
form.$buttons.find('.o_form_button_save').click();
|
||||
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user