diff options
| author | Géry Debongnie <ged@odoo.com> | 2017-05-19 11:01:06 +0200 |
|---|---|---|
| committer | Géry Debongnie <ged@odoo.com> | 2017-05-19 12:14:49 +0200 |
| commit | 92409cdfe5812c72f03ac96fab955db865f390c3 (patch) | |
| tree | d25426bed49f891b63133169554c99aeb64e7793 /addons/web/static/tests/fields/relational_fields_tests.js | |
| parent | 8af3d452f414135bd897026859958a9660bb5aa4 (diff) | |
[FIX] web: apply onchanges for sub fields for new records
Before this commit, when creating a new record, we only looked at the
main fields to determine if a call to onchange was needed. This was not
enough, since sub fields (fields in a one2many for example) can have an
onchange.
This was an issue only for new records with onchanges in sub fields, but
no onchange on main fields. For example, the merge contact wizard.
To solve this issue, we had to propagate the current view type from the
field to the basic model, because otherwise, the main viewtype was used
to compute the onchangeSpec, and that is not always correct.
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields_tests.js')
| -rw-r--r-- | addons/web/static/tests/fields/relational_fields_tests.js | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index 70dc16c6a40..1a8f2742e22 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -20,7 +20,7 @@ QUnit.module('relational_fields', { int_field: {string: "int_field", type: "integer", sortable: true}, qux: {string: "Qux", type: "float", digits: [16,1] }, p: {string: "one2many field", type: "one2many", relation: 'partner', relation_field: 'trululu'}, - turtles: {string: "one2many turtle field", type: "one2many", relation: 'turtle'}, + turtles: {string: "one2many turtle field", type: "one2many", relation: 'turtle', relation_field: 'turtle_trululu'}, trululu: {string: "Trululu", type: "many2one", relation: 'partner'}, timmy: { string: "pokemon", type: "many2many", relation: 'partner_type'}, product_id: {string: "Product", type: "many2one", relation: 'product'}, @@ -1336,12 +1336,14 @@ QUnit.module('relational_fields', { QUnit.test('one2many list (editable): edition, part 4', function (assert) { assert.expect(3); + var i = 0; this.data.turtle.onchanges = { turtle_trululu: function (obj) { - if (obj.turtle_trululu) { + if (i) { obj.turtle_description = "Some Description"; } + i++; }, }; @@ -2334,25 +2336,26 @@ QUnit.module('relational_fields', { }); QUnit.test('parent data is properly sent on an onchange rpc, new record', function (assert) { - assert.expect(1); + assert.expect(6); - this.data.partner.onchanges = {bar: function () {}}; + this.data.turtle.onchanges = {turtle_bar: function () {}}; var form = createView({ View: FormView, model: 'partner', data: this.data, arch: '<form string="Partners">' + '<field name="foo"/>' + - '<field name="p">' + + '<field name="turtles">' + '<tree editable="top">' + - '<field name="bar"/>' + + '<field name="turtle_bar"/>' + '</tree>' + '</field>' + '</form>', mockRPC: function (route, args) { - if (args.method === 'onchange') { + assert.step(args.method); + if (args.method === 'onchange' && args.model === 'turtle') { var fieldValues = args.args[1]; - assert.strictEqual(fieldValues.trululu.foo, "My little Foo Value", + assert.strictEqual(fieldValues.turtle_trululu.foo, "My little Foo Value", "should have properly sent the parent foo value"); } return this._super.apply(this, arguments); @@ -2361,6 +2364,7 @@ QUnit.module('relational_fields', { form.$buttons.find('.o_form_button_edit').click(); form.$('tbody td.o_field_x2many_list_row_add a').click(); + assert.verifySteps(['default_get', 'onchange', 'default_get', 'onchange']); form.destroy(); }); |
