diff options
Diffstat (limited to 'addons/web/static/src')
4 files changed, 36 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 diff --git a/addons/web/static/src/scss/form_view.scss b/addons/web/static/src/scss/form_view.scss index 812e6cbd6cc..99430bd0eed 100644 --- a/addons/web/static/src/scss/form_view.scss +++ b/addons/web/static/src/scss/form_view.scss @@ -570,6 +570,9 @@ &.o_form_readonly .o_field_widget .o_list_view .o_row_handle { display: none; // Hide the handler in non-edit mode } + .o_field_widget.o_readonly_modifier .o_list_view .o_row_handle { + display: none; // Hide the handler on readonly fields + } // Attachments .oe_attachment { |
