summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/views/basic_model_tests.js
diff options
context:
space:
mode:
authorfwi-odoo <fwi@odoo.com>2017-04-14 13:02:21 +0200
committerfwi-odoo <fwi@odoo.com>2017-04-20 16:41:59 +0200
commit86af036ea1175f4a9a5fbca806ab49665fdbc4b0 (patch)
treef9d69f2c5c5c766a9a457df59738fea4194a6250 /addons/web/static/tests/views/basic_model_tests.js
parent6da35f7140246d19755da913b4c84fdc16759474 (diff)
[FIX] web: fix various bugs when fetching x2manys in form views
- When an one2many is displayed in a list view, the field data are not fully loaded since only the number of record is displayed. Then when the related form view is opened the one2many fields displayed need to be loaded. - Optimized the fetch of x2manys without doing an useless rpc if we don't need all the fields but only the relation records ids and adapt the tests for this optimisation. - Fix wrong inheritance for kanbanmany2many_tags
Diffstat (limited to 'addons/web/static/tests/views/basic_model_tests.js')
-rw-r--r--addons/web/static/tests/views/basic_model_tests.js28
1 files changed, 24 insertions, 4 deletions
diff --git a/addons/web/static/tests/views/basic_model_tests.js b/addons/web/static/tests/views/basic_model_tests.js
index ac703c0d90b..ec9700b66f3 100644
--- a/addons/web/static/tests/views/basic_model_tests.js
+++ b/addons/web/static/tests/views/basic_model_tests.js
@@ -431,7 +431,7 @@ QUnit.module('Views', {
});
QUnit.test('fetch x2manys in list, with not too many rpcs', function (assert) {
- assert.expect(2);
+ assert.expect(3);
this.data.partner.records[0].category = [12, 15];
this.data.partner.records[1].category = [12, 14];
@@ -441,12 +441,11 @@ QUnit.module('Views', {
this.params.groupedBy = [];
this.params.res_id = undefined;
- var rpcCount = 0;
var model = createModel({
Model: BasicModel,
data: this.data,
mockRPC: function (route, args) {
- rpcCount++;
+ assert.step(route);
return this._super(route, args);
},
});
@@ -456,7 +455,8 @@ QUnit.module('Views', {
assert.strictEqual(record.data[0].data.category.data.length, 2,
"first record should have 2 categories loaded");
- assert.strictEqual(rpcCount, 2, "should have done 2 rpc (searchread and read category)");
+ assert.verifySteps(["/web/dataset/search_read"],
+ "should have done 2 rpc (searchread and read category)");
});
model.destroy();
});
@@ -1280,4 +1280,24 @@ QUnit.module('Views', {
model.destroy();
});
+ QUnit.test('load model with many2many field properly fetched', function (assert) {
+ assert.expect(2);
+
+ this.params.fieldNames = ['category'];
+ this.params.res_id = 1;
+
+ var model = createModel({
+ Model: BasicModel,
+ data: this.data,
+ mockRPC: function(route, args) {
+ assert.step(args.method);
+ return this._super(route, args);
+ },
+ });
+
+ model.load(this.params);
+ assert.verifySteps(['read'],
+ "there should be only one read");
+ model.destroy();
+ });
});});