diff options
| author | Christophe Simonis <chs@odoo.com> | 2017-08-10 17:01:05 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2017-08-10 17:01:05 +0200 |
| commit | 48b2ce60ed12b9b0f3aaa0322465504798bd154e (patch) | |
| tree | 0ac2c53a78f678ad4701943eb9eab6a4c8f5ff48 /addons/web/static/tests/views/basic_model_tests.js | |
| parent | 298eaca4d1e268c43185e9c1dd6d6973e02d9b57 (diff) | |
| parent | 85571bb78c9acc4e867cc3b480be9236a756fc22 (diff) | |
[MERGE] forward port branch saas-16 up to 85571bb78c9
Diffstat (limited to 'addons/web/static/tests/views/basic_model_tests.js')
| -rw-r--r-- | addons/web/static/tests/views/basic_model_tests.js | 59 |
1 files changed, 59 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 53577d90e40..8c23fc4f97c 100644 --- a/addons/web/static/tests/views/basic_model_tests.js +++ b/addons/web/static/tests/views/basic_model_tests.js @@ -956,6 +956,30 @@ QUnit.module('Views', { model.destroy(); }); + QUnit.test('group on date field with magic grouping method', function (assert) { + assert.expect(1); + + this.params.fieldNames = ['foo']; + this.params.groupedBy = ['date:month']; + this.params.res_id = undefined; + + var model = createModel({ + Model: BasicModel, + data: this.data, + mockRPC: function (route, args) { + if (args.method === 'read_group') { + assert.deepEqual(args.kwargs.fields, ['foo', 'date'], + "should have correctly trimmed the magic grouping info from the field name"); + } + return this._super.apply(this, arguments); + }, + }); + + model.load(this.params); + model.destroy(); + }); + + QUnit.test('read group when grouped by a selection field', function (assert) { assert.expect(5); @@ -1949,4 +1973,39 @@ QUnit.module('Views', { model.destroy(); }); + QUnit.test('reload a new record', function (assert) { + assert.expect(6); + + this.params.context = {}; + this.params.fieldNames = ['product_id', 'category', 'product_ids']; + this.params.res_id = undefined; + this.params.type = 'record'; + + 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).then(function (recordID) { + model.reload(recordID).then(function (recordID) { + assert.verifySteps(['default_get', 'default_get'], + "two default_get RPCs should have been done"); + var record = model.get(recordID); + assert.strictEqual(record.data.product_id, false, + "m2o default value should be false"); + assert.deepEqual(record.data.product_ids.data, [], + "o2m default should be []"); + assert.deepEqual(record.data.category.data, [], + "m2m default should be []"); + }); + }); + + model.destroy(); + }); + + });}); |
