diff options
| author | Géry Debongnie <ged@odoo.com> | 2017-07-06 09:34:25 +0200 |
|---|---|---|
| committer | Martin Geubelle <mge@odoo.com> | 2017-07-06 15:04:04 +0200 |
| commit | 56dae80994ceb27a80714bed78f4e17450151831 (patch) | |
| tree | 514a351b1b0b969ebc60b656947982afff0cd7e5 /addons/web/static/tests/fields/relational_fields_tests.js | |
| parent | 7dc731db8308febb6426ee4c6d61b2a80d40c021 (diff) | |
[FIX] web: prevent crash with invisible x2m and onchanges
When an invisible x2many field is modified by an onchange, we had a
crash because the reset function did not return a deferred in that case.
This happens because the signature of _render in AbstractField allow for
an undefined return value, but the reset method should return a
deferred.
This was an issue for example in stock: editing the
pack_operation_product_ids one2many field in a stock.picking could
trigger an onchange on another invisible one2many (with no inline views).
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields_tests.js')
| -rw-r--r-- | addons/web/static/tests/fields/relational_fields_tests.js | 32 |
1 files changed, 32 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 1704ffab34d..5c2a93ee775 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -4763,6 +4763,38 @@ QUnit.module('relational_fields', { form.destroy(); }); + QUnit.test('resetting invisible one2manys', function (assert) { + assert.expect(3); + + this.data.partner.records[0].turtles = []; + this.data.partner.onchanges.foo = function (obj) { + obj.turtles = [[5], [4, 1]]; + }; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '<form>' + + '<field name="foo"/>' + + '<field name="turtles" invisible="1"/>' + + '</form>', + viewOptions: { + mode: 'edit', + }, + res_id: 1, + mockRPC: function (route, args) { + assert.step(args.method); + return this._super.apply(this, arguments); + }, + }); + + form.$('input[name="foo"]').val('abcd').trigger('input'); + assert.verifySteps(['read', 'onchange']); + + form.destroy(); + }); + QUnit.module('FieldMany2Many'); QUnit.test('many2many kanban: edition', function (assert) { |
