diff options
| author | Kevin Baptiste <kba@odoo.com> | 2020-02-26 12:17:28 +0000 |
|---|---|---|
| committer | Kevin Baptiste <kba@odoo.com> | 2020-04-22 08:29:51 +0000 |
| commit | 53954ad93efba227efb2cb129ea1b95253a18f2a (patch) | |
| tree | 167a83cd42baf10ea0623394741ad9b5aad63a05 /addons/project/static | |
| parent | 12acf49f1520a9792b3de077cd50583ede39c572 (diff) | |
[IMP] project: ease stage deletion
Before this commit, deleting a stage with tasks, the user received an
error.
With this commit, when deleting a stage containing tasks, a wizard
offers the choice to move the tasks to another stage.
closes odoo/odoo#46410
Taskid: 1869030
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Diffstat (limited to 'addons/project/static')
| -rw-r--r-- | addons/project/static/src/js/project_kanban.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/addons/project/static/src/js/project_kanban.js b/addons/project/static/src/js/project_kanban.js new file mode 100644 index 00000000000..812bfc165bc --- /dev/null +++ b/addons/project/static/src/js/project_kanban.js @@ -0,0 +1,48 @@ +odoo.define('project.project_kanban', function (require) { +'use strict'; + +var KanbanController = require('web.KanbanController'); +var KanbanView = require('web.KanbanView'); +var KanbanColumn = require('web.KanbanColumn'); +var view_registry = require('web.view_registry'); + +var ProjectKanbanController = KanbanController.extend({ + custom_events: _.extend({}, KanbanController.prototype.custom_events, { + 'kanban_column_delete_wizard': '_onDeleteColumnWizard', + }), + + _onDeleteColumnWizard: function (ev) { + ev.stopPropagation(); + const self = this; + const column_id = ev.target.id; + var state = this.model.get(this.handle, {raw: true}); + this._rpc({ + model: 'project.task.type', + method: 'unlink_wizard', + args: [column_id], + context: state.getContext(), + }).then(function (res) { + self.do_action(res); + }); + } +}); + +var ProjectKanbanView = KanbanView.extend({ + config: _.extend({}, KanbanView.prototype.config, { + Controller: ProjectKanbanController + }), +}); + +KanbanColumn.include({ + _onDeleteColumn: function (event) { + event.preventDefault(); + if (this.modelName === 'project.task') { + this.trigger_up('kanban_column_delete_wizard'); + return; + } + this._super.apply(this, arguments); + } +}); + +view_registry.add('project_kanban', ProjectKanbanView); +}); |
