From b8c1571d948e593779b83ba78130c341f1e427cd Mon Sep 17 00:00:00 2001 From: David Monjoie Date: Wed, 14 Jun 2017 14:35:38 +0200 Subject: [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. --- addons/web/static/src/js/views/basic/basic_model.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src/js/views/basic/basic_model.js') 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); }) -- cgit v1.2.3