diff options
| author | Aaron Bohy <aab@odoo.com> | 2019-09-06 09:15:45 +0000 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2019-09-18 11:28:03 +0000 |
| commit | 2cdd46b566d00aa6c8e6bb9452c3edde120ce2a3 (patch) | |
| tree | 979a882d7b8eece14b67eb43eceff9bd39d268b7 /addons/web/static/tests | |
| parent | 63289fa06a6ffeb7f5919ba888d7e84d0b16418f (diff) | |
[FIX] web: list: multi edition: force write same value
Let's assume an editable list view with a many2one field and 2
records: the first one has value 1, the second value 2. The user
selects all records and wants to set their many2one to value 1. It
edits the first one, sets 1 and validates the confirm dialog.
Before this rev., it didn't save anything because the 'reference'
record (the one used to edit), didn't actually changed, as we reset
the same value.
This rev. forces the write the new value on all selected records in
that case.
Task 2068280
Diffstat (limited to 'addons/web/static/tests')
| -rw-r--r-- | addons/web/static/tests/views/list_tests.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js index 6724540a23f..7f2ff62e293 100644 --- a/addons/web/static/tests/views/list_tests.js +++ b/addons/web/static/tests/views/list_tests.js @@ -5411,6 +5411,44 @@ QUnit.module('Views', { list.destroy(); }); + QUnit.test('editable list view: multi edition of many2one: set same value', async function (assert) { + assert.expect(4); + + var list = await createView({ + View: ListView, + model: 'foo', + data: this.data, + arch: '<tree editable="bottom">' + + '<field name="foo"/>' + + '<field name="m2o"/>' + + '</tree>', + mockRPC: function (route, args) { + if (args.method === 'write') { + assert.deepEqual(args.args, [[1, 2, 3, 4], { m2o: 1 }], + "should force write value on all selected records"); + } + return this._super.apply(this, arguments); + }, + }); + + assert.strictEqual(list.$('.o_list_many2one').text(), "Value 1Value 2Value 1Value 1"); + + // select all records (the first one has value 1 for m2o) + await testUtils.dom.click(list.$('thead .o_list_record_selector input')); + + // set m2o to 1 in first record + await testUtils.dom.click(list.$('.o_data_row:eq(0) .o_data_cell:eq(1)')); + await testUtils.fields.many2one.searchAndClickItem('m2o', {search: 'Value 1'}); + + assert.containsOnce(document.body, '.modal'); + + await testUtils.dom.click($('.modal .modal-footer .btn-primary')); + + assert.strictEqual(list.$('.o_list_many2one').text(), "Value 1Value 1Value 1Value 1"); + + list.destroy(); + }); + QUnit.test('editable list view: multi edition with readonly modifiers', async function (assert) { assert.expect(5); |
