summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/basic_fields_tests.js
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2017-11-20 15:17:23 +0100
committerGéry Debongnie <ged@odoo.com>2017-11-20 16:29:11 +0100
commitfd7b767637cd9563e9869adf537150867925f120 (patch)
tree4c9f1ff2a7dc6790a5ca22dce72c92e3cc280b86 /addons/web/static/tests/fields/basic_fields_tests.js
parentd5e51717d518a9efd6246704a96e14fce963470e (diff)
[FIX] web: empty field char should be set to false
With the new views, empty char fields were sent to the server as '' (empty string) instead of false. This is not the correct behaviour, and actually cause some problems. For example, if you have a char field with a unicity constraint, then you cannot set it to '', since there is only one record that can take that value.
Diffstat (limited to 'addons/web/static/tests/fields/basic_fields_tests.js')
-rw-r--r--addons/web/static/tests/fields/basic_fields_tests.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js
index c6feea74b77..30e5d477882 100644
--- a/addons/web/static/tests/fields/basic_fields_tests.js
+++ b/addons/web/static/tests/fields/basic_fields_tests.js
@@ -718,6 +718,38 @@ QUnit.module('basic_fields', {
form.destroy();
});
+ QUnit.test('setting a char field to empty string is saved as a false value', function (assert) {
+ assert.expect(1);
+
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form string="Partners">' +
+ '<sheet>' +
+ '<group>' +
+ '<field name="foo"/>' +
+ '</group>' +
+ '</sheet>' +
+ '</form>',
+ res_id: 1,
+ viewOptions: {mode: 'edit'},
+ mockRPC: function (route, args) {
+ if (args.method === 'write') {
+ assert.strictEqual(args.args[1].foo, false,
+ 'the foo value should be false');
+ }
+ return this._super.apply(this, arguments);
+ }
+ });
+
+ form.$('input[type="text"].o_field_widget').val('').trigger('input');
+
+ // save
+ form.$buttons.find('.o_form_button_save').click();
+ form.destroy();
+ });
+
QUnit.test('char field with size attribute', function (assert) {
assert.expect(1);