summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/views/basic_model_tests.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/tests/views/basic_model_tests.js')
-rw-r--r--addons/web/static/tests/views/basic_model_tests.js59
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();
+ });
+
+
});});