From ac490b1b3e4d9c74b8d4de281b8fd511874d7d6c Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Fri, 5 May 2017 11:01:53 +0200 Subject: [FIX] web: better factorize debounced/input fields code `DebouncedField` and `InputField` classes were not properly factorized, some of the DebouncedField code had to be part of the `InputField` class (which is a specialization of `DebouncedField`). Indeed the `FieldText` class, specialization of `DebouncedField` class, was missing properties which were part of `InputField` and was duplicating code which was already defined in `InputField`. For example, it was not possible to navigate out of text fields in editable list views with the right/left keys as this was part of the `InputField` class. Note: the FieldTextHtmlSimple class was implementing the `commitChanges` function differently than `DebouncedField` but this was in fact not necessary. This is why documentation update has also been done for this by this commit. --- .../web/static/src/js/views/basic/basic_controller.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'addons/web/static/src/js/views/basic/basic_controller.js') 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 87e8d1a6664..b7cd40d9e7c 100644 --- a/addons/web/static/src/js/views/basic/basic_controller.js +++ b/addons/web/static/src/js/views/basic/basic_controller.js @@ -166,15 +166,16 @@ var BasicController = AbstractController.extend(FieldManagerMixin, { * @returns {Deferred} */ saveRecord: function (recordID, options) { - // Some field widgets (e.g. 'html') can't detect (all) their changes, so - // we ask them to commit their current value before saving. This has to - // be done outside of the mutex protection of saving because - // commitChanges will trigger changes and these are also protected. So - // the actual saving has to be done after these changes. Also the - // commitChanges operation might not be synchronous for other reason - // (e.g. the x2m fields will ask the user if some discarding has to be - // made). This operation must also be mutex-protected as commitChanges - // function of x2m has to be aware of all final changes made to a row. + // Some field widgets can't detect (all) their changes immediately or + // may have to validate them before notifying them, so we ask them to + // commit their current value before saving. This has to be done outside + // of the mutex protection of saving because commitChanges will trigger + // changes and these are also protected. So the actual saving has to be + // done after these changes. Also the commitChanges operation might not + // be synchronous for other reason (e.g. the x2m fields will ask the + // user if some discarding has to be made). This operation must also be + // mutex-protected as commitChanges function of x2m has to be aware of + // all final changes made to a row. this.mutex.exec(this.renderer.commitChanges.bind(this.renderer, recordID || this.handle)); // TODO write a test for this return this.mutex.exec(this._saveRecord.bind(this, recordID, options)); }, -- cgit v1.2.3