summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/relational_fields_tests.js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2017-06-26 15:40:09 +0200
committerAaron Bohy <aab@odoo.com>2017-06-27 14:12:31 +0200
commit9fbed63406702b43e41262da24d68f63feb582f0 (patch)
tree5afe24d5e40e18a32fd85a175e6e942050cd8b42 /addons/web/static/tests/fields/relational_fields_tests.js
parent7ea6f653df0863e9c0dbaf0b07800c0277b962b1 (diff)
[FIX] web: FieldSelection on m2o: unset value
When the value of a many2one field with widget selection was unset, it's value wasn't actually set to false in the BasicModel. It was set to a virtual id like 'virtual_294' instead. This caused a traceback when this value was sent to the server, obviously. This was for example the case of the Register Payment form view (accessible from a customer invoice), when the user selected a payment journal, and then unselected it (the virtual id was then sent to the onchange RPC).
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields_tests.js')
-rw-r--r--addons/web/static/tests/fields/relational_fields_tests.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js
index f179bbc7621..e67faabe220 100644
--- a/addons/web/static/tests/fields/relational_fields_tests.js
+++ b/addons/web/static/tests/fields/relational_fields_tests.js
@@ -5797,6 +5797,35 @@ QUnit.module('relational_fields', {
form.destroy();
});
+ QUnit.test('unset selection on a many2one field', function (assert) {
+ assert.expect(1);
+
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form string="Partners">' +
+ '<field name="trululu" widget="selection"/>' +
+ '</form>',
+ mockRPC: function (route, args) {
+ if (args.method === 'write') {
+ assert.strictEqual(args.args[1].trululu, false,
+ "should send 'false' as trululu value");
+ }
+ return this._super.apply(this, arguments);
+ },
+ res_id: 1,
+ viewOptions: {
+ mode: 'edit',
+ },
+ });
+
+ form.$('select').val("false").trigger('change');
+ form.$buttons.find('.o_form_button_save').click();
+
+ form.destroy();
+ });
+
QUnit.module('FieldMany2ManyTags');
QUnit.test('fieldmany2many tags: rendering and edition', function (assert) {