diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-03-13 16:52:40 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-03-13 16:52:40 +0100 |
| commit | afe8e97800328d6cc9f98e114d9b9ab5509f85af (patch) | |
| tree | bf6bc62a00f8dbb640b283e6cb5f66e62874a9c7 /addons/web/static/src | |
| parent | ecd8c023b7c58809438e462a43bc2dd405afa122 (diff) | |
| parent | c23d1186e7bb49495f8ae02f6451658a891988fa (diff) | |
[MERGE] forward port branch 11.0 up to c23d1186e7b
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 eb89a939903..9413f09041f 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -3328,6 +3328,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) { @@ -3335,6 +3336,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; @@ -3352,7 +3356,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 2b38ca4403d..75793239979 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 6b6baa1ec74..849216f7d86 100644 --- a/addons/web/static/src/js/views/form/form_controller.js +++ b/addons/web/static/src/js/views/form/form_controller.js @@ -358,6 +358,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. * * @override diff --git a/addons/web/static/src/less/form_view.less b/addons/web/static/src/less/form_view.less index b28aecc58b1..2e1eff1110a 100644 --- a/addons/web/static/src/less/form_view.less +++ b/addons/web/static/src/less/form_view.less @@ -592,6 +592,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 { |
