summaryrefslogtreecommitdiff
path: root/addons/web/static/test/views/basic_model_tests.js
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2017-02-24 14:03:58 +0100
committerAaron Bohy <aab@odoo.com>2017-04-11 19:44:38 +0200
commit4a612171b3bf85f2902c582fcc658eea668a732e (patch)
tree2e8c628788fcd4b99048d827ab08235b630031fb /addons/web/static/test/views/basic_model_tests.js
parent064d7f462122bd5193e094d8b03c132cb43d14a2 (diff)
[FIX] web: basic model now parse dates on lists
Before this commit, the BasicModel didn't parse the dates when loading data for a list. But the rest of the web client assumes that data is properly parsed into their correct types, so a moment instance for date and datetime. Also, uppercase field_utils and properly reorder imports
Diffstat (limited to 'addons/web/static/test/views/basic_model_tests.js')
-rw-r--r--addons/web/static/test/views/basic_model_tests.js33
1 files changed, 29 insertions, 4 deletions
diff --git a/addons/web/static/test/views/basic_model_tests.js b/addons/web/static/test/views/basic_model_tests.js
index b68383fc9ca..2624fb77c8c 100644
--- a/addons/web/static/test/views/basic_model_tests.js
+++ b/addons/web/static/test/views/basic_model_tests.js
@@ -19,10 +19,11 @@ QUnit.module('Views', {
product_id: {string: "Favorite product", type: 'many2one', relation: 'product'},
product_ids: {string: "Favorite products", type: 'one2many', relation: 'product'},
category: {string: "Category M2M", type: 'many2many', relation: 'partner_type'},
+ date: {string: "Date Field", type: 'date'},
},
records: [
- {id: 1, foo: 'blip', bar: 1, product_id: 37, category: [12], display_name: "first partner"},
- {id: 2, foo: 'gnap', bar: 2, product_id: 41, display_name: "second partner"},
+ {id: 1, foo: 'blip', bar: 1, product_id: 37, category: [12], display_name: "first partner", date: "2017-01-25"},
+ {id: 2, foo: 'gnap', bar: 2, product_id: 41, display_name: "second partner", date: "2017-01-26"},
],
onchanges: {},
},
@@ -717,5 +718,29 @@ QUnit.module('Views', {
});
-});
-});
+ QUnit.test('dates are properly loaded and parsed', function (assert) {
+ assert.expect(1);
+
+
+ var model = createModel({
+ Model: BasicModel,
+ data: this.data,
+ });
+
+ var params = {
+ fieldNames: ['date'],
+ fields: this.data.partner.fields,
+ modelName: 'partner',
+ type: 'list',
+ };
+
+ model.load(params).then(function (resultID) {
+ var record = model.get(resultID);
+ var firstRecord = record.data[0];
+ assert.ok(firstRecord.data.date instanceof moment,
+ "fetched date field should have been formatted");
+ });
+ });
+
+
+});});