summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/views/abstract_controller.js10
-rw-r--r--addons/web/static/src/js/views/basic/basic_controller.js4
-rw-r--r--addons/web/static/src/js/views/form/form_controller.js11
-rw-r--r--addons/web/static/src/js/views/list/list_renderer.js2
4 files changed, 19 insertions, 8 deletions
diff --git a/addons/web/static/src/js/views/abstract_controller.js b/addons/web/static/src/js/views/abstract_controller.js
index 53bcc0d5bad..07a0109e9a7 100644
--- a/addons/web/static/src/js/views/abstract_controller.js
+++ b/addons/web/static/src/js/views/abstract_controller.js
@@ -136,8 +136,11 @@ var AbstractController = mvc.Controller.extend(ActionMixin, {
* @override
*/
canBeRemoved: function () {
- // AAB: get rid of this option when on_hashchange mechanism is improved
- return this.discardChanges(undefined, {readonlyIfRealDiscard: true});
+ // AAB: get rid of 'readonlyIfRealDiscard' option when on_hashchange mechanism is improved
+ return this.discardChanges(undefined, {
+ noAbandon: true,
+ readonlyIfRealDiscard: true,
+ });
},
/**
* Discards the changes made on the record associated to the given ID, or
@@ -151,9 +154,10 @@ var AbstractController = mvc.Controller.extend(ActionMixin, {
*
* @param {string} [recordID]
* if not given, we consider all the changes made by the controller
+ * @param {Object} [options]
* @returns {Promise} resolved if properly discarded, rejected otherwise
*/
- discardChanges: function (recordID) {
+ discardChanges: function (recordID, options) {
return Promise.resolve();
},
/**
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 610e7e6dc6b..e76aec046e8 100644
--- a/addons/web/static/src/js/views/basic/basic_controller.js
+++ b/addons/web/static/src/js/views/basic/basic_controller.js
@@ -374,14 +374,16 @@ var BasicController = AbstractController.extend(FieldManagerMixin, {
* the new record to be in edit mode too, but the view manager calls
* this function as the URL changes...) @todo get rid of this when
* the webclient/action_manager's hashchange mechanism is improved.
+ * @param {boolean} [options.noAbandon=false]
* @returns {Promise}
*/
_discardChanges: function (recordID, options) {
var self = this;
recordID = recordID || this.handle;
+ options = options || {};
return this.canBeDiscarded(recordID)
.then(function (needDiscard) {
- if (options && options.readonlyIfRealDiscard && !needDiscard) {
+ if (options.noAbandon || (options.readonlyIfRealDiscard && !needDiscard)) {
return;
}
self.model.discardChanges(recordID);
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 b3a65cc2bde..83edf12212b 100644
--- a/addons/web/static/src/js/views/form/form_controller.js
+++ b/addons/web/static/src/js/views/form/form_controller.js
@@ -49,13 +49,18 @@ var FormController = BasicController.extend({
this.autofocus();
},
/**
- * Force mode back to readonly. Whenever we leave a form view, it is saved,
- * and should no longer be in edit mode.
+ * This hook is called when a form view is restored (by clicking on the
+ * breadcrumbs). In general, we force mode back to readonly, because
+ * whenever we leave a form view by stacking another action on the top of
+ * it, it is saved, and should no longer be in edit mode. However, there is
+ * a special case for new records for which we still want to be in 'edit'
+ * as no record has been created (changes have been discarded before
+ * leaving).
*
* @override
*/
willRestore: function () {
- this.mode = 'readonly';
+ this.mode = this.model.isNew(this.handle) ? 'edit' : 'readonly';
},
//--------------------------------------------------------------------------
diff --git a/addons/web/static/src/js/views/list/list_renderer.js b/addons/web/static/src/js/views/list/list_renderer.js
index abc487a98fb..b4d6e5e036b 100644
--- a/addons/web/static/src/js/views/list/list_renderer.js
+++ b/addons/web/static/src/js/views/list/list_renderer.js
@@ -620,7 +620,7 @@ var ListRenderer = BasicRenderer.extend({
var $pager = this._renderGroupPager(group);
$lastCell.addClass('o_group_pager').append($pager);
}
- if (group.isOpen && this.groupbys[groupBy]) {
+ if (groupLevel === 0 && group.isOpen && this.groupbys[groupBy]) {
var $buttons = this._renderGroupButtons(group, this.groupbys[groupBy]);
if ($buttons.length) {
var $buttonSection = $('<div>', {