summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorfwi-odoo <fwi@odoo.com>2017-09-30 12:05:42 +0200
committerfwi-odoo <fwi@odoo.com>2017-09-30 13:21:02 +0200
commit0f98d59064532675cf36ff33a70ee072e2ce2123 (patch)
tree5e5202b3dfd6c1ef07d99b1b87fbc5bbf74d5df6 /addons/web/static/src
parent0e562c8a7d825cd6c162093422fb023c643ec3df (diff)
[FIX] web: calendar avoid double event creation
Before this commit, pressing tab then enter was generating a traceback because the event creation and modal deletion was done twice. This commit adds a protection to be sure that we are doing only one event creation.
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/views/calendar/calendar_controller.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/addons/web/static/src/js/views/calendar/calendar_controller.js b/addons/web/static/src/js/views/calendar/calendar_controller.js
index 8d27acb43dd..4168d901065 100644
--- a/addons/web/static/src/js/views/calendar/calendar_controller.js
+++ b/addons/web/static/src/js/views/calendar/calendar_controller.js
@@ -48,6 +48,8 @@ var CalendarController = AbstractController.extend({
this.readonlyFormViewId = params.readonlyFormViewId;
this.mapping = params.mapping;
this.context = params.context;
+ // The quickCreating attribute ensures that we don't do several create
+ this.quickCreating = false;
},
//--------------------------------------------------------------------------
@@ -153,18 +155,26 @@ var CalendarController = AbstractController.extend({
*/
_onQuickCreate: function (event) {
var self = this;
+ if (this.quickCreating) {
+ return;
+ }
+ this.quickCreating = true;
this.model.createRecord(event)
.then(function (id) {
self.quick.destroy();
self.quick = null;
self.reload(id);
- }, function (error, errorEvent) {
+ })
+ .fail(function (error, errorEvent) {
// This will occurs if there are some more fields required
// Preventdefaulting the error event will prevent the traceback window
errorEvent.preventDefault();
event.data.options.disableQuickCreate = true;
event.data.data.on_save = self.quick.destroy.bind(self.quick);
self._onOpenCreate(event.data);
+ })
+ .always(function () {
+ self.quickCreating = false;
});
},
/**