summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2017-04-22 20:56:27 +0200
committerGéry Debongnie <ged@odoo.com>2017-04-24 10:13:54 +0200
commitd8261d1162086e5c299e9ee364b7ac0476ea6fee (patch)
treec323e164fff14afbaa6e59cbcc7ade723b6c25ee /addons/web/static/src
parent1561165fe25c33ea773d76710b2c94e7d71968d4 (diff)
[FIX] web: fix issues when deleting records
This commit solves two issues with deletion: - deleting the last record in a form view now triggers a history_back action, which means that the view will be changed back to the main view (a list view for example), instead of staying in form view - deleting a record did reload the view twice in some cases.
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/views/basic/basic_model.js8
-rw-r--r--addons/web/static/src/js/views/form/form_controller.js13
2 files changed, 14 insertions, 7 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 62898a338bd..e737df9cc9e 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -183,17 +183,14 @@ var BasicModel = AbstractModel.extend({
* parent.
*
* @todo we should remove the deleted records from the localData
- * @todo is it really necessary to reload the data? it seems artificial, and
- * the caller should be able to do that himself
* @todo why can't we infer modelName?
*
* @param {string[]} recordIds list of local resources ids. They should all
* be of type 'record', and of the same model
* @param {string} modelName
- * @param {string} parentID
* @returns {Deferred}
*/
- deleteRecords: function (recordIds, modelName, parentID) {
+ deleteRecords: function (recordIds, modelName) {
var self = this;
var records = _.map(recordIds, function (id) { return self.localData[id]; });
return this._rpc({
@@ -208,9 +205,6 @@ var BasicModel = AbstractModel.extend({
record.res_id = record.res_ids[record.offset];
record.count--;
});
- if (parentID) {
- return self.reload(parentID);
- }
});
},
/**
diff --git a/addons/web/static/src/js/views/form/form_controller.js b/addons/web/static/src/js/views/form/form_controller.js
index 778768b4982..e833c80e3b2 100644
--- a/addons/web/static/src/js/views/form/form_controller.js
+++ b/addons/web/static/src/js/views/form/form_controller.js
@@ -338,6 +338,19 @@ var FormController = BasicController.extend({
this.do_warn(_t("The following fields are invalid:"), warnings.join(''));
},
/**
+ * Hook method, called when record(s) has been deleted.
+ *
+ * @override
+ */
+ _onDeletedRecords: function () {
+ var state = this.model.get(this.handle, {raw: true});
+ if (!state.res_ids.length) {
+ this.do_action('history_back');
+ } else {
+ this._super.apply(this, arguments);
+ }
+ },
+ /**
* We just add the current ID to the state pushed. This allows the web
* client to add it in the url, for example.
*