diff options
| author | David Monjoie <dmo@odoo.com> | 2017-09-29 14:01:51 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-09-30 09:04:29 +0200 |
| commit | 8d1630a40adbac8f9cd70a8ef0e7b9b61b7a60e8 (patch) | |
| tree | 43c5ea56e00120eceb75b09ccdedf0487096da7f /addons/web/static/tests/fields | |
| parent | e4672db97da1df7c297aafbea93b9ffa26da5e4e (diff) | |
[FIX] web: fix one2many default get
The one2many default get code used to meddle with basic_model's res_ids
manually, which ended up desynchronizing the data and res_ids fields
of the list representation of the one2many values.
This commit solves the issue by using the proper mechanisms of the
basic_model, that is creating a proper datapoint for those ids.
Steps to reproduce the original issue:
- Install sale_mamangement, mrp and purchase
- Create a product
- In the Inventory tab, in Routes, uncheck Buy
- Check and then uncheck back any other route than Buy
- Get a traceback because we are looking for a record with a given
res_id in the list data but since they are desynchronized, data
is empty at that point even though res_ids is not.
Diffstat (limited to 'addons/web/static/tests/fields')
| -rw-r--r-- | addons/web/static/tests/fields/relational_fields_tests.js | 47 |
1 files changed, 47 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 ab19f58a344..3b841276060 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -6249,6 +6249,53 @@ QUnit.module('relational_fields', { form.destroy(); }); + QUnit.test('many2many checkboxes with default values', function (assert) { + assert.expect(7); + + this.data.partner.fields.turtles.default = [3]; + this.data.partner.fields.turtles.type = "many2many"; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch:'<form string="Partners">' + + '<field name="turtles" widget="many2many_checkboxes">' + + '</field>' + + '</form>', + mockRPC: function (route, args) { + if (args.method === 'create') { + assert.deepEqual(args.args[0].turtles, [[6, false, [1]]], + "correct values should have been sent to create"); + } + return this._super.apply(this, arguments); + } + }); + + assert.notOk(form.$('.o_checkbox input').eq(0).prop('checked'), + "first checkbox should not be checked"); + assert.notOk(form.$('.o_checkbox input').eq(1).prop('checked'), + "second checkbox should not be checked"); + assert.ok(form.$('.o_checkbox input').eq(2).prop('checked'), + "third checkbox should be checked"); + + form.$('.o_checkbox input:checked').click(); // Uncheck default record + form.$('.o_checkbox input').first().click(); // Check first record + form.$('.o_checkbox input').first().click(); // Uncheck first record + form.$('.o_checkbox input').first().click(); // Recheck first record + + assert.ok(form.$('.o_checkbox input').eq(0).prop('checked'), + "first checkbox should be checked"); + assert.notOk(form.$('.o_checkbox input').eq(1).prop('checked'), + "second checkbox should not be checked"); + assert.notOk(form.$('.o_checkbox input').eq(2).prop('checked'), + "third checkbox should not be checked"); + + form.$buttons.find('.o_form_button_save').click(); + + form.destroy(); + }); + QUnit.test('many2many list with x2many: add a record', function (assert) { assert.expect(18); |
