summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorYannick Tivisse <yti@odoo.com>2019-07-11 16:02:05 +0200
committerYannick Tivisse <yti@odoo.com>2019-07-12 13:01:36 +0200
commit71d4116ea379f204d5773d829dce624fbcf67ec5 (patch)
treed6c4cef922554843283577c2cdb1149683c2bebf /addons/web/static/src
parent1680b171a31b0f42e04b613ea97966717887455a (diff)
[IMP] web: Make archive:unarchive buttons manage returned actions
Purpose ======= When calling toggle_active, you may sometimes retrieve an action to execute. For example, when archiving an employee, it opens a wizard to provide information about the departure, and choose an offboarding plan. This commit modifies the way toggleActive, actionArchive and actionUnarchive works to manage this behavior.
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/views/basic/basic_model.js36
1 files changed, 30 insertions, 6 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 311b0ee6947..ca0c7829a2c 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -1187,10 +1187,18 @@ var BasicModel = AbstractModel.extend({
method: 'toggle_active',
args: [resIDs],
})
- .then(function () {
+ .then(function (action) {
// optionally clear the DataManager's cache
self._invalidateCache(parent);
- return self.reload(parentID);
+ if (!_.isEmpty(action)) {
+ return self.do_action(action, {
+ on_close: function () {
+ return self.reload(parentID);
+ }
+ });
+ } else {
+ return self.reload(parentID);
+ }
});
},
/**
@@ -1211,10 +1219,18 @@ var BasicModel = AbstractModel.extend({
method: 'action_archive',
args: [resIDs],
})
- .then(function () {
+ .then(function (action) {
// optionally clear the DataManager's cache
self._invalidateCache(parent);
- return self.reload(parentID);
+ if (!_.isEmpty(action)) {
+ return self.do_action(action, {
+ on_close: function () {
+ return self.reload(parentID);
+ }
+ });
+ } else {
+ return self.reload(parentID);
+ }
});
},
/**
@@ -1235,10 +1251,18 @@ var BasicModel = AbstractModel.extend({
method: 'action_unarchive',
args: [resIDs],
})
- .then(function () {
+ .then(function (action) {
// optionally clear the DataManager's cache
self._invalidateCache(parent);
- return self.reload(parentID);
+ if (!_.isEmpty(action)) {
+ return self.do_action(action, {
+ on_close: function () {
+ return self.reload(parentID);
+ }
+ });
+ } else {
+ return self.reload(parentID);
+ }
});
},
/**