summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorChristophe Matthieu <chm@odoo.com>2018-02-05 16:55:15 +0100
committerChristophe Matthieu <chm@odoo.com>2018-02-08 15:46:41 +0100
commit3b9dda6106f9dd3eabd5dcb14f484a6072937dd6 (patch)
treecc6217ae4fc0834e21bccb1179e97d724d780260 /addons/web/static/src
parent0bd8c0ddc88b7fb1c94f7c15a727e06b1d9b918d (diff)
[FIX] web: Views: always destroy BasicModel instances
Before this rev., it might happen that the parent of BasicModel instances wasn't correctly set to the Controller instance. It was actually set to the ActionManager instance, which is never destroyed. So when this happened, the BasicModel instance wasn't destroyed when it's controller was.
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/views/abstract_view.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/addons/web/static/src/js/views/abstract_view.js b/addons/web/static/src/js/views/abstract_view.js
index 2a1ba16a33e..dea984adb64 100644
--- a/addons/web/static/src/js/views/abstract_view.js
+++ b/addons/web/static/src/js/views/abstract_view.js
@@ -138,21 +138,23 @@ var AbstractView = Class.extend({
*/
getController: function (parent) {
var self = this;
+ // check if a model already exists, as if not, one will be created and
+ // we'll have to set the controller as its parent
+ var alreadyHasModel = !!this.model;
return $.when(this._loadData(parent), ajax.loadLibs(this)).then(function () {
- var model = self.getModel();
- var state = model.get(arguments[0]);
+ var state = self.model.get(arguments[0]);
var renderer = self.getRenderer(parent, state);
var Controller = self.Controller || self.config.Controller;
var controllerParams = _.extend({
initialState: state,
}, self.controllerParams);
- var controller = new Controller(parent, model, renderer, controllerParams);
+ var controller = new Controller(parent, self.model, renderer, controllerParams);
renderer.setParent(controller);
- if (!self.model) {
+ if (!alreadyHasModel) {
// if we have a model, it already has a parent. Otherwise, we
// set the controller, so the rpcs from the model actually work
- model.setParent(controller);
+ self.model.setParent(controller);
}
return controller;
});