diff options
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_model.js')
| -rw-r--r-- | addons/web/static/src/js/views/basic/basic_model.js | 82 |
1 files changed, 77 insertions, 5 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 60c2f6a3314..ca0c7829a2c 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -1176,7 +1176,7 @@ var BasicModel = AbstractModel.extend({ * @param {string} parentID id of the parent resource to reload * @returns {Promise<string>} resolves to the parent id */ - toggleActive: function (recordIDs, value, parentID) { + toggleActive: function (recordIDs, parentID) { var self = this; var parent = this.localData[parentID]; var resIDs = _.map(recordIDs, function (recordID) { @@ -1184,13 +1184,85 @@ var BasicModel = AbstractModel.extend({ }); return this._rpc({ model: parent.model, - method: 'write', - args: [resIDs, { active: value }], + 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); + } + }); + }, + /** + * Archive the given records + * + * @param {Array} recordIDs local ids of the records to (un)archive + * @param {string} parentID id of the parent resource to reload + * @returns {Promise<string>} resolves to the parent id + */ + actionArchive: function (recordIDs, parentID) { + var self = this; + var parent = this.localData[parentID]; + var resIDs = _.map(recordIDs, function (recordID) { + return self.localData[recordID].res_id; + }); + return this._rpc({ + model: parent.model, + method: 'action_archive', + args: [resIDs], + }) + .then(function (action) { + // optionally clear the DataManager's cache + self._invalidateCache(parent); + if (!_.isEmpty(action)) { + return self.do_action(action, { + on_close: function () { + return self.reload(parentID); + } + }); + } else { + return self.reload(parentID); + } + }); + }, + /** + * Unarchive the given records + * + * @param {Array} recordIDs local ids of the records to (un)archive + * @param {string} parentID id of the parent resource to reload + * @returns {Promise<string>} resolves to the parent id + */ + actionUnarchive: function (recordIDs, parentID) { + var self = this; + var parent = this.localData[parentID]; + var resIDs = _.map(recordIDs, function (recordID) { + return self.localData[recordID].res_id; + }); + return this._rpc({ + model: parent.model, + method: 'action_unarchive', + args: [resIDs], + }) + .then(function (action) { + // optionally clear the DataManager's cache + self._invalidateCache(parent); + if (!_.isEmpty(action)) { + return self.do_action(action, { + on_close: function () { + return self.reload(parentID); + } + }); + } else { + return self.reload(parentID); + } }); }, /** |
