summaryrefslogtreecommitdiff
path: root/addons/web/static/tests
diff options
context:
space:
mode:
authorLucas Perais (lpe) <lpe@odoo.com>2021-02-12 10:49:34 +0000
committerLucas Perais (lpe) <lpe@odoo.com>2021-02-15 09:44:04 +0000
commit8b6e86927941dce2018ea93f191b59856ea67e4b (patch)
treee98e6d5e11da6864d8e183840012d76e60e94249 /addons/web/static/tests
parent23fcaeda6830f2dc0de17337f9c3da8faf0338ce (diff)
[FIX] web: multiedit in a grouped list view: enable fetchBatchedM2O and References
Have grouped list with reference a m2o or a reference field Select some records, edit them Before this commit: the names of the reference fields and m2o disappeared That was because the saveRecords function did not take into account a grouped list manual forward port of #65999 After this commit: it works as expected closes odoo/odoo#66043 closes odoo/odoo#66140 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
Diffstat (limited to 'addons/web/static/tests')
-rw-r--r--addons/web/static/tests/views/list_tests.js76
1 files changed, 76 insertions, 0 deletions
diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js
index 5c30d59593c..481ec86a6e8 100644
--- a/addons/web/static/tests/views/list_tests.js
+++ b/addons/web/static/tests/views/list_tests.js
@@ -7250,6 +7250,82 @@ QUnit.module('Views', {
list.destroy();
});
+ QUnit.test('multi edit reference field batched in grouped list', async function (assert) {
+ assert.expect(18);
+
+ this.data.foo.records= [
+ // group 1
+ {id: 1, foo: '1', reference: 'bar,1'},
+ {id: 2, foo: '1', reference: 'bar,2'},
+ //group 2
+ {id: 3, foo: '2', reference: 'res_currency,1'},
+ {id: 4, foo: '2', reference: 'bar,2'},
+ {id: 5, foo: '2', reference: 'bar,3'},
+ ];
+ // Field boolean_toggle just to simplify the test flow
+ let nameGetCount = 0;
+ const list = await createView({
+ View: ListView,
+ model: 'foo',
+ data: this.data,
+ arch: `<tree expand="1" multi_edit="1">
+ <field name="foo" invisible="1"/>
+ <field name="bar" widget="boolean_toggle"/>
+ <field name="reference"/>
+ </tree>`,
+ groupBy: ['foo'],
+ mockRPC: function (route, args) {
+ assert.step(args.method || route);
+ if (args.method === 'write') {
+ assert.deepEqual(args.args, [[1,2,3], {bar: true}]);
+ }
+ if (args.method === 'name_get') {
+ if (nameGetCount === 2) {
+ assert.strictEqual(args.model, 'bar');
+ assert.deepEqual(args.args[0], [1,2]);
+ }
+ if (nameGetCount === 3) {
+ assert.strictEqual(args.model, 'res_currency');
+ assert.deepEqual(args.args[0], [1]);
+ }
+ nameGetCount++;
+ }
+ return this._super.apply(this, arguments);
+ },
+ });
+
+ assert.verifySteps([
+ 'web_read_group',
+ 'name_get',
+ 'name_get',
+ ]);
+ await testUtils.dom.click(list.$('.o_data_row .o_list_record_selector input')[0]);
+ await testUtils.dom.click(list.$('.o_data_row .o_list_record_selector input')[1]);
+ await testUtils.dom.click(list.$('.o_data_row .o_list_record_selector input')[2]);
+ await testUtils.dom.click(list.$('.o_data_row .o_field_boolean')[0]);
+ assert.containsOnce(document.body, '.modal');
+ await testUtils.dom.click($('.modal .modal-footer .btn-primary'));
+ assert.containsNone(document.body, '.modal');
+ assert.verifySteps([
+ 'write',
+ 'read',
+ 'name_get',
+ 'name_get',
+ ]);
+ assert.containsN(list, '.o_group_header', 2);
+
+ const allNames = Array.from(list.el.querySelectorAll('.o_data_cell'))
+ .filter(node => !node.children.length).map(n=>n.textContent);
+ assert.deepEqual(allNames, [
+ 'Value 1',
+ 'Value 2',
+ 'USD',
+ 'Value 2',
+ 'Value 3',
+ ]);
+ list.destroy();
+ });
+
QUnit.test('editable list view: contexts are correctly sent', async function (assert) {
assert.expect(6);