summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/views/basic_model_tests.js
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-03-09 16:25:58 +0100
committerChristophe Simonis <chs@odoo.com>2018-03-09 16:25:58 +0100
commit0f57bdba72b592ca097d4cd3da99a75883d8c623 (patch)
tree94eef0c9aaf885c7f717bab5e468ca72b59a219d /addons/web/static/tests/views/basic_model_tests.js
parent35f0797002e44ce5673e9fab63710d2764329694 (diff)
parent42659dc70c2b9b124e7e4fdc0449f660c3de5c76 (diff)
[MERGE] forward port branch saas-11.2 up to 42659dc70c2
Diffstat (limited to 'addons/web/static/tests/views/basic_model_tests.js')
-rw-r--r--addons/web/static/tests/views/basic_model_tests.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/addons/web/static/tests/views/basic_model_tests.js b/addons/web/static/tests/views/basic_model_tests.js
index 492dfd4224c..bf5261c5b6e 100644
--- a/addons/web/static/tests/views/basic_model_tests.js
+++ b/addons/web/static/tests/views/basic_model_tests.js
@@ -669,6 +669,42 @@ QUnit.module('Views', {
model.destroy();
});
+ QUnit.test('default_get returning a non requested field', function (assert) {
+ // 'default_get' returns a default value for the fields given in
+ // arguments. It should not return a value for fields that have not be
+ // requested. However, it happens (e.g. res.users), and the webclient
+ // should not crash when this situation occurs (the field should simply
+ // be ignored).
+ assert.expect(2);
+
+ this.params.context = {};
+ this.params.fieldNames = ['category'];
+ this.params.res_id = undefined;
+ this.params.type = 'record';
+
+ var model = createModel({
+ Model: BasicModel,
+ data: this.data,
+ mockRPC: function (route, args) {
+ var result = this._super(route, args);
+ if (args.method === 'default_get') {
+ result.product_ids = [[6, 0, [37, 41]]];
+ }
+ return result;
+ },
+ });
+
+ model.load(this.params).then(function (resultID) {
+ var record = model.get(resultID);
+ assert.ok('category' in record.data,
+ "should have processed 'category'");
+ assert.notOk('product_ids' in record.data,
+ "should have ignored 'product_ids'");
+ });
+
+ model.destroy();
+ });
+
QUnit.test('can make a default_record with default relational values', function (assert) {
assert.expect(7);