summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2019-01-09 11:21:42 +0000
committerAaron Bohy <aab@odoo.com>2019-01-14 11:29:53 +0000
commit141c9a0ced5280aa9d6a7068c880f1e949e52fee (patch)
treeb362431c3739940d0275f10a813d4719c442dcdd /addons/web/static/src/js
parentb4387108de968e3e80cd43d6df746049b0e3fbc8 (diff)
[FIX] web: kanban: quick create columns and records
This rev. fixes a concurrency issue in the kanban view spotted by the Project tour and the removal of the delay in the tour system. Let's assume the following scenario in a kanban view grouped by a many2one field with at least one column and with the quick create feature enabled: - quick create a new column - before the column is actually created, click on CREATE in the control panel to create a new record Before this rev., the record quick create widget was opened directly, but as soon as the column was created, the view was re-rendered, and the quick create widget was lost. This rev. forces the column to be created (and the view to be re-rendered) before opening the record quick create.
Diffstat (limited to 'addons/web/static/src/js')
-rw-r--r--addons/web/static/src/js/views/kanban/kanban_controller.js29
1 files changed, 18 insertions, 11 deletions
diff --git a/addons/web/static/src/js/views/kanban/kanban_controller.js b/addons/web/static/src/js/views/kanban/kanban_controller.js
index 6ffbad9612a..cf3404ae420 100644
--- a/addons/web/static/src/js/views/kanban/kanban_controller.js
+++ b/addons/web/static/src/js/views/kanban/kanban_controller.js
@@ -210,15 +210,17 @@ var KanbanController = BasicController.extend({
*/
_onAddColumn: function (event) {
var self = this;
- this.model.createGroup(event.data.value, this.handle).then(function () {
- var state = self.model.get(self.handle, {raw: true});
- var ids = _.pluck(state.data, 'res_id').filter(_.isNumber);
- return self._resequenceColumns(ids);
- }).then(function () {
- return self.update({}, {reload: false});
- }).then(function () {
- self._updateButtons();
- self.renderer.quickCreateToggleFold();
+ this.mutex.exec(function () {
+ return self.model.createGroup(event.data.value, self.handle).then(function () {
+ var state = self.model.get(self.handle, {raw: true});
+ var ids = _.pluck(state.data, 'res_id').filter(_.isNumber);
+ return self._resequenceColumns(ids);
+ }).then(function () {
+ return self.update({}, {reload: false});
+ }).then(function () {
+ self._updateButtons();
+ self.renderer.quickCreateToggleFold();
+ });
});
},
/**
@@ -271,11 +273,16 @@ var KanbanController = BasicController.extend({
* @private
*/
_onButtonNew: function () {
+ var self = this;
var state = this.model.get(this.handle, {raw: true});
var quickCreateEnabled = this.quickCreateEnabled && viewUtils.isQuickCreateEnabled(state);
if (this.on_create === 'quick_create' && quickCreateEnabled && state.data.length) {
- // Activate the quick create in the first column
- this.renderer.addQuickCreate();
+ // activate the quick create in the first column when the mutex is
+ // unlocked, to ensure that there is no pending re-rendering that
+ // would remove it (e.g. if we are currently adding a new column)
+ this.mutex.getUnlockedDef().then(function () {
+ self.renderer.addQuickCreate();
+ });
} else if (this.on_create && this.on_create !== 'quick_create') {
// Execute the given action
this.do_action(this.on_create, {