summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic/basic_model.js
diff options
context:
space:
mode:
authorDavid Monjoie <dmo@odoo.com>2017-06-14 14:35:38 +0200
committerDavid Monjoie <dmo@odoo.com>2017-06-19 07:56:42 +0200
commitb8c1571d948e593779b83ba78130c341f1e427cd (patch)
tree1e4370dd8f4647eedc8b614e50fcfb51d2cf7902 /addons/web/static/src/js/views/basic/basic_model.js
parent584c60f1ba7627230f0db445d167332344f83bfb (diff)
[FIX] web: prevent crash when giving wrong id in url
The mock server had to be modified in order to test this behavior since it used to throw an error for invalid ids, while the actual server just ignores it and continues forth with the other ids.
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_model.js')
-rw-r--r--addons/web/static/src/js/views/basic/basic_model.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js
index d897a74c696..1ace44be50f 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -1399,7 +1399,8 @@ var BasicModel = AbstractModel.extend({
* @param {string} [optinos.viewType] the type of view for which the record
* is fetched (usefull to load the adequate fields), by defaults, uses
* record.viewType
- * @returns {Deferred -> Object} resolves to the record
+ * @returns {Deferred -> Object} resolves to the record or is rejected in
+ * case no id given were valid ids
*/
_fetchRecord: function (record, options) {
var self = this;
@@ -1412,6 +1413,9 @@ var BasicModel = AbstractModel.extend({
context: _.extend({}, record.context, {bin_size: true}),
})
.then(function (result) {
+ if (result.length === 0) {
+ return $.Deferred().reject();
+ }
result = result[0];
record.data = _.extend({}, record.data, result);
})