diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-03-14 14:13:47 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-03-14 14:13:47 +0100 |
| commit | 9a4e84ae6670a6ce7086174a3f33f2eee8ded0a3 (patch) | |
| tree | 6a89fa5e6afe9120abda03cfbd32e27cf6cf4768 /addons/web/static/src/js | |
| parent | 5625257991d8997c453aee26b5f05ef85925824e (diff) | |
| parent | f5ab04ce5098bb3c3e88ca18ba6b533e6139f8e5 (diff) | |
[MERGE] forward port branch saas-11.3 up to f5ab04ce509
Diffstat (limited to 'addons/web/static/src/js')
| -rw-r--r-- | addons/web/static/src/js/views/basic/basic_model.js | 6 | ||||
| -rw-r--r-- | addons/web/static/src/js/views/field_manager_mixin.js | 15 | ||||
| -rw-r--r-- | addons/web/static/src/js/views/form/form_controller.js | 13 |
3 files changed, 33 insertions, 1 deletions
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 b21c4b55eff..cb48e09fe98 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -3492,6 +3492,7 @@ var BasicModel = AbstractModel.extend({ var res_id, value; var res_ids = params.res_ids || []; var data = params.data || (type === 'record' ? {} : []); + var context = params.context; if (type === 'record') { res_id = params.res_id || (params.data && params.data.id); if (res_id) { @@ -3499,6 +3500,9 @@ var BasicModel = AbstractModel.extend({ } else { res_id = _.uniqueId('virtual_'); } + // it doesn't make sense for a record datapoint to have those keys + // besides, it will mess up x2m and actions down the line + context = _.omit(context, ['orderedBy', 'group_by']); } else { var isValueArray = params.value instanceof Array; res_id = isValueArray ? params.value[0] : undefined; @@ -3516,7 +3520,7 @@ var BasicModel = AbstractModel.extend({ _domains: {}, _rawChanges: {}, aggregateValues: params.aggregateValues || {}, - context: params.context, + context: context, count: params.count || res_ids.length, data: data, domain: params.domain || [], diff --git a/addons/web/static/src/js/views/field_manager_mixin.js b/addons/web/static/src/js/views/field_manager_mixin.js index bc61e92a89a..ab441b4f75a 100644 --- a/addons/web/static/src/js/views/field_manager_mixin.js +++ b/addons/web/static/src/js/views/field_manager_mixin.js @@ -52,6 +52,8 @@ var FieldManagerMixin = { if (event.data.force_save) { return self.model.save(dataPointID).then(function () { return self._confirmSave(dataPointID); + }).fail(function () { + return self._rejectSave(dataPointID); }); } else if (options.notifyChange !== false) { return self._confirmChange(dataPointID, result, event); @@ -84,6 +86,19 @@ var FieldManagerMixin = { _confirmSave: function (id) { return $.when(); }, + /** + * This method will be called whenever a save has been triggered by a change + * and has failed. For example, when a statusbar button is clicked in a + * readonly form view. + * + * @abstract + * @private + * @param {string} id The basicModel ID for the saved record + * @returns {Deferred} + */ + _rejectSave: function (id) { + return $.when(); + }, //-------------------------------------------------------------------------- // Handlers 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 45b68ce6bea..434e2095a8e 100644 --- a/addons/web/static/src/js/views/form/form_controller.js +++ b/addons/web/static/src/js/views/form/form_controller.js @@ -368,6 +368,19 @@ var FormController = BasicController.extend({ this._super(state); }, /** + * Overrides to reload the form when saving failed in readonly (e.g. after + * a change on a widget like priority or statusbar). + * + * @override + * @private + */ + _rejectSave: function () { + if (this.mode === 'readonly') { + return this.reload(); + } + return this._super.apply(this, arguments); + }, + /** * Calls unfreezeOrder when changing the mode. * Also, when there is a change of mode, the tracking of last activated * field is reset, so that the following field activation process starts |
