diff options
| author | Aaron Bohy <aab@odoo.com> | 2017-05-31 08:29:00 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-05-31 20:53:55 +0200 |
| commit | 23613b411feb6571c0f2907d8c88a7e8f8e39d87 (patch) | |
| tree | 95a48c63e3b7c73d1a3239d278775c177bc1376c /addons/web/static/src/js/views/basic/basic_controller.js | |
| parent | 5ff7199562132ccefd69ce84ce0c2c2984a40e26 (diff) | |
[FIX] web: x2m editable list: wait for onchanges
... before saving a line.
Suppose that we have an editable list with one required field
(e.g. many2one) with an onchange. We add a record and select a value
for the many2one. Before the onchange returns, we click again on
'Add an item'. If we don't wait for the onchange to return before
unselecting the row (i.e. before saving it), a confirm dialog asking
if the changes can be discarded opens, because the line isn't valid
yet. This could easily be reproduced on the sale_order form view,
with some throttling.
This rev. ensures that we wait for the onchange to return before
saving the line, and thus before creating a new line.
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_controller.js')
| -rw-r--r-- | addons/web/static/src/js/views/basic/basic_controller.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/addons/web/static/src/js/views/basic/basic_controller.js b/addons/web/static/src/js/views/basic/basic_controller.js index f58b858db9e..9f767799851 100644 --- a/addons/web/static/src/js/views/basic/basic_controller.js +++ b/addons/web/static/src/js/views/basic/basic_controller.js @@ -19,6 +19,7 @@ var _t = core._t; var BasicController = AbstractController.extend(FieldManagerMixin, { custom_events: _.extend({}, AbstractController.prototype.custom_events, FieldManagerMixin.custom_events, { discard_changes: '_onDiscardChanges', + mutexify: '_onMutexify', reload: '_onReload', sidebar_data_asked: '_onSidebarDataAsked', translate: '_onTranslate', @@ -500,6 +501,14 @@ var BasicController = AbstractController.extend(FieldManagerMixin, { FieldManagerMixin._onFieldChanged.apply(this, arguments); }, /** + * @private + * @param {OdooEvent} ev + * @param {function} ev.data.action the function to execute in the mutex + */ + _onMutexify: function (ev) { + this.mutex.exec(ev.data.action); + }, + /** * When a reload event triggers up, we need to reload the full view. * For example, after a form view dialog saved some data. * |
