summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/views
diff options
context:
space:
mode:
authorLucas Perais (lpe) <lpe@odoo.com>2021-02-12 15:16:39 +0000
committerLucas Perais (lpe) <lpe@odoo.com>2021-02-15 09:43:33 +0000
commit23fcaeda6830f2dc0de17337f9c3da8faf0338ce (patch)
tree4a90869157b304017b82280c0daa91e773c04d11 /addons/web/static/tests/views
parente1fc6707ed4ddfe7c62e6beead8617e5fbe6ea9b (diff)
[FIX] web: list multi edit: prevent force save
Have a list with multi_edit enabled Have a widget boolean_toggle displayed on some field Select some records to be in multi edit mode Before this commit, the record on which the boolean toggle button was clicked was written and then the multi edit feature was triggered and wrote on all the records The first write is unnecessary and counter intuitive After this commit, only the write with all the multi edited records is done
Diffstat (limited to 'addons/web/static/tests/views')
-rw-r--r--addons/web/static/tests/views/list_tests.js38
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 b9b747dbc7d..5c30d59593c 100644
--- a/addons/web/static/tests/views/list_tests.js
+++ b/addons/web/static/tests/views/list_tests.js
@@ -7709,6 +7709,44 @@ QUnit.module('Views', {
list.destroy();
});
+ QUnit.test('editable list view (multi edition): writable fields in readonly (force save)', async function (assert) {
+ assert.expect(7);
+
+ // boolean toogle widget allows for writing on the record even in readonly mode
+ const list = await createView({
+ arch: `
+ <tree multi_edit="1">
+ <field name="bar" widget="boolean_toggle"/>
+ </tree>`,
+ data: this.data,
+ model: 'foo',
+ View: ListView,
+ mockRPC(route, args) {
+ assert.step(args.method || route);
+ if (args.method === 'write') {
+ assert.deepEqual(args.args, [[1,3], {bar: false}]);
+ }
+ return this._super(...arguments);
+ }
+ });
+
+ assert.verifySteps(['/web/dataset/search_read']);
+ // select two records
+ await testUtils.dom.click(list.$('.o_data_row:eq(0) .o_list_record_selector input'));
+ await testUtils.dom.click(list.$('.o_data_row:eq(2) .o_list_record_selector input'));
+
+ await testUtils.dom.click(list.$('.o_data_row .o_field_boolean')[0]);
+
+ assert.ok($('.modal').text().includes("Confirmation"), "Modal should ask to save changes");
+ await testUtils.dom.click($('.modal .btn-primary'));
+ assert.verifySteps([
+ 'write',
+ 'read',
+ ]);
+
+ list.destroy();
+ });
+
QUnit.test('editable list view: multi edition with readonly modifiers', async function (assert) {
assert.expect(5);