diff options
Diffstat (limited to 'addons/web/static/tests/views/basic_model_tests.js')
| -rw-r--r-- | addons/web/static/tests/views/basic_model_tests.js | 36 |
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); |
