summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/abstract_controller.js
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2017-03-24 13:20:52 +0100
committerAaron Bohy <aab@odoo.com>2017-04-11 19:44:38 +0200
commit0250e60dd2d9038dc3f6a3306a470f8d3af87515 (patch)
tree09a249e7336dc7a35a7e52e25bb7d4ceb59ee328 /addons/web/static/src/js/views/abstract_controller.js
parent6a8e7acc6783b440451728291f3dfcd5917b62e5 (diff)
[FIX] web: check if changes can be discarded before leaving view
Before this commit, we did not check if the changes can be discarded when opening the app switcher. This is now done. Note that this check was formerly done in the form view, and we moved this to the view manager. This now means that all views have the power to decide if they can be discarded.
Diffstat (limited to 'addons/web/static/src/js/views/abstract_controller.js')
-rw-r--r--addons/web/static/src/js/views/abstract_controller.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/addons/web/static/src/js/views/abstract_controller.js b/addons/web/static/src/js/views/abstract_controller.js
index 3d9db03eb1c..9344d3a9e21 100644
--- a/addons/web/static/src/js/views/abstract_controller.js
+++ b/addons/web/static/src/js/views/abstract_controller.js
@@ -64,6 +64,22 @@ var AbstractController = Widget.extend({
//--------------------------------------------------------------------------
/**
+ * Determines if we can discard the current state. For example, when the
+ * user open the 'home' screen, the view manager will call this method on
+ * the active view to make sure it is ok to open the home screen (and
+ * potentially loose all current state).
+ *
+ * Note that it returns a deferred, because the view could choose to ask the
+ * user if he agrees to discard.
+ *
+ * @override
+ * @returns {Deferred} If the deferred is resolved, we assume the changes
+ * can be discarded. If it is rejected, then we cannot discard.
+ */
+ canBeDiscarded: function () {
+ return $.when();
+ },
+ /**
* Returns any special keys that may be useful when reloading the view to
* get the same effect. This is necessary for saving the current view in
* the favorites. For example, a graph view might want to add a key to