diff options
| author | Aaron Bohy <aab@odoo.com> | 2018-01-19 08:39:26 +0100 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2018-01-19 09:57:41 +0100 |
| commit | ac0e4528904064cc85fe47ef3a2d211edd634f0c (patch) | |
| tree | 60a13b445a7f048eccd331ca1c1fede077ac2989 /addons/web/static/src | |
| parent | 66a95d91aa8e64f8a791c0be9a43c9d4446d2a1e (diff) | |
[FIX] web: Kanban: create several records on slow network
Before this rev., it crashed when the user used the quick create
to create several records (very quickly, or on a slow network),
e.g. on crm.lead (there must be a date field on the kanban record
to reproduce the crash).
The crash occurred when the 'read' RPCs for the created records
return misordered. For instance:
1) 'name_create' record 1 (called and returned)
2) call 'read' for record 1
3) 'name_create' record 2 (called and returned)
4) call 'read' for record 2
5) 'read' for record 2 returns
6) 'read' for record 1 returns
At step 5, the kanban column was updated with the new state, but
this state already contained record 1, which wasn't fetched yet.
This rev. ensures that the created records are added to the state
once they are fetched and ready to be displayed, not before.
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/views/kanban/kanban_model.js | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/addons/web/static/src/js/views/kanban/kanban_model.js b/addons/web/static/src/js/views/kanban/kanban_model.js index aba59555e93..df6172f0d8b 100644 --- a/addons/web/static/src/js/views/kanban/kanban_model.js +++ b/addons/web/static/src/js/views/kanban/kanban_model.js @@ -22,6 +22,7 @@ var KanbanModel = BasicModel.extend({ * @returns {Deferred<string>} resolves to the local id of the new record */ addRecordToGroup: function (groupID, resId) { + var self = this; var group = this.localData[groupID]; var new_record = this._makeDataPoint({ res_id: resId, @@ -31,15 +32,16 @@ var KanbanModel = BasicModel.extend({ viewType: group.viewType, parentID: groupID, }); - group.data.unshift(new_record.id); - group.res_ids.unshift(resId); - group.count++; - - // update the res_ids and count of the parent - this.localData[group.parentID].count++; - this._updateParentResIDs(group); return this._fetchRecord(new_record).then(function (result) { + group.data.unshift(new_record.id); + group.res_ids.unshift(resId); + group.count++; + + // update the res_ids and count of the parent + self.localData[group.parentID].count++; + self._updateParentResIDs(group); + return result.id; }); }, |
