summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/relational_fields_tests.js
diff options
context:
space:
mode:
authorKhoi Nguyen <bng@odoo.com>2017-10-11 10:00:29 +0200
committerKhoi Nguyen <khoi@nguyen.me.uk>2017-10-16 11:34:39 +0200
commit9f7af9f9b742d08ca69a4d4d0b963f625c4b4bba (patch)
treec317468abba71a502c47bd271a1b2523bebae832 /addons/web/static/tests/fields/relational_fields_tests.js
parentbb692c76d41bb308ef24e729f907d707c44b99ca (diff)
[FIX] web: ticking a checkbox in an x2many after onchange
This commits fixes a traceback that appears when ticking a checkbox in an x2many which triggers an onchange. The root cause of the issue is twofold: - confirmUpdate requires currentFieldIndex to be defined, but might be needed when setting currentFieldIndex; - confirmUpdate attempts to restore the selection range even if we are not dealing with a char field (e.g. checkbox). We solve the issue by ensuring that _selectCell gives a temporary value to currentFieldIndex. This value is chosen so that confirmUpdate calls _selectCell with the right parameters. Moreover, we only restore the selection range when the range is defined.
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 641546b3fc1..824b68c520d 100644
--- a/addons/web/static/tests/fields/relational_fields_tests.js
+++ b/addons/web/static/tests/fields/relational_fields_tests.js
@@ -6248,6 +6248,35 @@ QUnit.module('relational_fields', {
form.destroy();
});
+ QUnit.test('checkbox in an x2many that triggers an onchange', function (assert) {
+ assert.expect(1);
+
+ this.data.partner.onchanges = {
+ bar: function () {}
+ };
+
+ var form = createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: '<form string="Partners">' +
+ '<field name="p">' +
+ '<tree editable="bottom">' +
+ '<field name="bar"/>' +
+ '</tree>' +
+ '</field>' +
+ '</form>',
+ });
+
+ form.$('.o_field_x2many_list_row_add a').click();
+
+ form.$('.o_field_widget[name=bar] input').click();
+ assert.notOk(form.$('.o_field_widget[name=bar] input').prop('checked'),
+ "the checkbox should be unticked");
+
+ form.destroy();
+ });
+
QUnit.test('one2many with default value: edit line to make it invalid', function (assert) {
assert.expect(3);