diff options
Diffstat (limited to 'addons/web/static/src')
5 files changed, 66 insertions, 11 deletions
diff --git a/addons/web/static/src/js/chrome/action_manager.js b/addons/web/static/src/js/chrome/action_manager.js index 0fe45f011e8..f98447c8983 100644 --- a/addons/web/static/src/js/chrome/action_manager.js +++ b/addons/web/static/src/js/chrome/action_manager.js @@ -391,10 +391,13 @@ var ActionManager = Widget.extend({ } return this._startController(controller).then(function (controller) { + var prevDialogOnClose; if (self.currentDialogController) { + prevDialogOnClose = self.currentDialogController.onClose; self._closeDialog(true); } + controller.onClose = prevDialogOnClose || options.on_close; var dialog = new Dialog(self, _.defaults({}, options, { buttons: [], dialogClass: controller.className, @@ -405,7 +408,7 @@ var ActionManager = Widget.extend({ self._removeAction(action.jsID); self.currentDialogController = null; if (silent !== true) { - options.on_close(); + controller.onClose(); } }); controller.dialog = dialog; @@ -488,8 +491,9 @@ var ActionManager = Widget.extend({ * @returns {Deferred} resolved immediately */ _executeCloseAction: function (action, options) { + var result; if (!this.currentDialogController) { - options.on_close(); + result = options.on_close(); } this._closeDialog(); @@ -499,7 +503,7 @@ var ActionManager = Widget.extend({ this.trigger_up('show_effect', action.effect); } - return $.when(); + return $.when(result); }, /** * Executes actions of type 'ir.actions.server'. diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index 43b4e349a66..d007305dc79 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -2516,6 +2516,21 @@ var AceEditor = DebouncedField.extend({ //-------------------------------------------------------------------------- /** + * Format value + * + * Note: We have to overwrite this method to always return a string. + * AceEditor works with string and not boolean value. + * + * @override + * @private + * @param {boolean|string} value + * @returns {string} + */ + _formatValue: function (value) { + return this._super.apply(this, arguments) || ''; + }, + + /** * @override * @private */ @@ -2537,6 +2552,7 @@ var AceEditor = DebouncedField.extend({ this.aceSession.setValue(newValue); } }, + /** * Starts the ace library on the given DOM element. This initializes the * ace editor option according to the edit/readonly mode and binds ace diff --git a/addons/web/static/src/js/services/crash_manager.js b/addons/web/static/src/js/services/crash_manager.js index 8d15efda686..f3bfa87341c 100644 --- a/addons/web/static/src/js/services/crash_manager.js +++ b/addons/web/static/src/js/services/crash_manager.js @@ -41,7 +41,8 @@ var CrashManager = core.Class.extend({ core.bus.trigger('connection_lost'); this.connection_lost = true; var timeinterval = setInterval(function() { - ajax.jsonRpc('/web/webclient/version_info').then(function() { + var options = {shadow: true}; + ajax.jsonRpc('/web/webclient/version_info', 'call', {}, options).then(function () { clearInterval(timeinterval); core.bus.trigger('connection_restored'); self.connection_lost = false; diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js index ffa93fc4d78..9d509dd703c 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -584,13 +584,16 @@ var BasicModel = AbstractModel.extend({ /** * Returns true if a record can be abandoned. * - * A record can be abandonned if it is a new record, except if - * this datapoint has been specifically tagged as "do not abandon". + * Case for not abandoning the record: * - * Example: + * 1. flagged as 'no abandon' (i.e. during a `default_get`, including any + * `onchange` from a `default_get`) + * 2. registered in a list on addition + * 2.1. registered as non-new addition + * 2.2. registered as new additon on update + * 3. record is not new * - * - Discard record from "Add an item" => "New" record => abandon - * - Discard record from `default_get`/`onchange` => do not abandon + * Otherwise, the record can be abandoned. * * This is useful when discarding changes on this record, as it means that * we must keep the record even if some fields are invalids (e.g. required @@ -600,7 +603,29 @@ var BasicModel = AbstractModel.extend({ * @returns {boolean} */ canBeAbandoned: function (id) { - return !this.localData[id]._noAbandon && this.isNew(id); + // 1. no drop if flagged + if (this.localData[id]._noAbandon) { + return false; + } + // 2. no drop in a list on "ADD in some cases + var record = this.localData[id]; + var parent = this.localData[record.parentID]; + if (parent) { + var entry = _.findWhere(parent._savePoint, {operation: 'ADD', id: id}); + if (entry) { + // 2.1. no drop on non-new addition in list + if (!entry.isNew) { + return false; + } + // 2.2. no drop on new addition on "UPDATE" + var lastEntry = _.last(parent._savePoint); + if (lastEntry.operation === 'UPDATE' && lastEntry.id === id) { + return false; + } + } + } + // 3. drop new records + return this.isNew(id); }, /** * Returns true if a record is dirty. A record is considered dirty if it has @@ -2571,6 +2596,11 @@ var BasicModel = AbstractModel.extend({ relationField: field.relation_field, viewType: view ? view.type : fieldInfo.viewType, }); + // set existing changes to the list + if (record._changes && record._changes[fieldName]) { + list._changes = self.localData[record._changes[fieldName]]._changes; + record._changes[fieldName] = list.id; + } record.data[fieldName] = list.id; if (!fieldInfo.__no_fetch) { var def = self._readUngroupedList(list).then(function () { diff --git a/addons/web/static/src/js/views/form/form_controller.js b/addons/web/static/src/js/views/form/form_controller.js index be49c12e768..d0ca5c3d09f 100644 --- a/addons/web/static/src/js/views/form/form_controller.js +++ b/addons/web/static/src/js/views/form/form_controller.js @@ -634,7 +634,11 @@ var FormController = BasicController.extend({ */ _onSave: function (ev) { ev.stopPropagation(); // Prevent x2m lines to be auto-saved - this.saveRecord(); + var self = this; + this._disableButtons(); + this.saveRecord().always(function () { + self._enableButtons(); + }); }, /** * This method is called when someone tries to sort a column, most likely |
