[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.
This commit is contained in:
Yannick Tivisse
2019-07-12 13:01:36 +02:00
parent 1680b171a3
commit 71d4116ea3
2 changed files with 31 additions and 6 deletions
+1
View File
@@ -291,6 +291,7 @@ class HrEmployeePrivate(models.Model):
'view_mode': 'form',
'target': 'new',
'context': {'active_id': self.id},
'views': [[False, 'form']]
}
return res
@@ -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);
}
});
},
/**