[FIX] web: display action menu in form/list view
The recent refactoring of the control panel moved the sidebar management from the action manager to the view itself. However, the sidebar parameter was forgotten, which resulted in the fact that it was no longer created. This fix was a little tricky, because the sidebar needs to be instantiated in some tests, but not in most of them (in particular, the document application changes its behaviour, which is annoying). closes odoo/odoo#29389
This commit is contained in:
@@ -105,7 +105,7 @@ var AbstractView = Factory.extend({
|
||||
this.arch = this.fieldsView.arch;
|
||||
this.fields = this.fieldsView.viewFields;
|
||||
this.userContext = params.userContext || {};
|
||||
this.withControlPanel = params.withControlPanel;
|
||||
this.withControlPanel = this.withControlPanel && params.withControlPanel;
|
||||
|
||||
// the boolean parameter 'isEmbedded' determines if the view should be
|
||||
// considered as a subview. For now this is only used by the graph
|
||||
|
||||
@@ -26,13 +26,20 @@ var FormView = BasicView.extend({
|
||||
* @override
|
||||
*/
|
||||
init: function (viewInfo, params) {
|
||||
var hasSidebar = params.hasSidebar;
|
||||
this._super.apply(this, arguments);
|
||||
|
||||
var mode = params.mode || (params.currentId ? 'readonly' : 'edit');
|
||||
this.loadParams.type = 'record';
|
||||
|
||||
// this is kind of strange, but the param object is modified by
|
||||
// AbstractView, so we only need to use its hasSidebar value if it was
|
||||
// not already present in the beginning of this method
|
||||
if (hasSidebar === undefined) {
|
||||
hasSidebar = params.hasSidebar;
|
||||
}
|
||||
this.controllerParams.hasSidebar = hasSidebar;
|
||||
this.controllerParams.disableAutofocus = params.disable_autofocus;
|
||||
this.controllerParams.hasSidebar = params.hasSidebar;
|
||||
this.controllerParams.toolbarActions = viewInfo.toolbar;
|
||||
this.controllerParams.footerToButtons = params.footerToButtons;
|
||||
|
||||
@@ -63,7 +70,6 @@ var FormView = BasicView.extend({
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @param {string} [action.target]
|
||||
*/
|
||||
_extractParamsFromAction: function (action) {
|
||||
var params = this._super.apply(this, arguments);
|
||||
@@ -73,6 +79,7 @@ var FormView = BasicView.extend({
|
||||
params.withControlPanel = !(inDialog || inline);
|
||||
params.footerToButtons = inDialog;
|
||||
params.hasSearchView = inDialog ? false : params.hasSearchView;
|
||||
params.hasSidebar = !inDialog && !inline;
|
||||
params.searchMenuTypes = inDialog ? [] : params.searchMenuTypes;
|
||||
if (inDialog || inline || fullscreen) {
|
||||
params.mode = 'edit';
|
||||
|
||||
@@ -57,8 +57,18 @@ var ListView = BasicView.extend({
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Private
|
||||
//---
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
_extractParamsFromAction: function (action) {
|
||||
var params = this._super.apply(this, arguments);
|
||||
var inDialog = action.target === 'new';
|
||||
var inline = action.target === 'inline';
|
||||
params.hasSidebar = !inDialog && !inline;
|
||||
return params;
|
||||
},
|
||||
_updateMVCParams: function () {
|
||||
this._super.apply(this, arguments);
|
||||
this.controllerParams.noLeaf = !!this.loadParams.context.group_by_no_leaf;
|
||||
|
||||
@@ -2126,6 +2126,22 @@ QUnit.module('ActionManager', {
|
||||
actionManager.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('sidebar is present in list view', function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
var actionManager = createActionManager({
|
||||
actions: this.actions,
|
||||
archs: this.archs,
|
||||
data: this.data,
|
||||
});
|
||||
actionManager.doAction(3);
|
||||
|
||||
assert.isNotVisible(actionManager.$('.o_cp_sidebar button.o_dropdown_toggler_btn:contains("Action")'));
|
||||
testUtils.dom.clickFirst(actionManager.$('input.custom-control-input'));
|
||||
assert.isVisible(actionManager.$('.o_cp_sidebar button.o_dropdown_toggler_btn:contains("Action")'));
|
||||
actionManager.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('can switch between views', function (assert) {
|
||||
assert.expect(18);
|
||||
|
||||
|
||||
@@ -135,6 +135,7 @@ function createAsyncView(params) {
|
||||
currentId: 'res_id' in params ? params.res_id : undefined,
|
||||
domain: params.domain || [],
|
||||
context: params.context || {},
|
||||
hasSidebar: false,
|
||||
});
|
||||
// patch the View to handle the groupBy given in params, as we can't give it
|
||||
// in init (unlike the domain and context which can be set in the action)
|
||||
|
||||
@@ -465,7 +465,7 @@ QUnit.module('Views', {
|
||||
});
|
||||
|
||||
QUnit.test('quick create record with quick_create_view', function (assert) {
|
||||
assert.expect(17);
|
||||
assert.expect(19);
|
||||
|
||||
var kanban = createView({
|
||||
View: KanbanView,
|
||||
@@ -497,6 +497,7 @@ QUnit.module('Views', {
|
||||
},
|
||||
});
|
||||
|
||||
assert.containsOnce(kanban, '.o_cp_controller', 'should have one control panel');
|
||||
assert.containsOnce(kanban, '.o_kanban_group:first .o_kanban_record',
|
||||
"first column should contain one record");
|
||||
|
||||
@@ -508,6 +509,7 @@ QUnit.module('Views', {
|
||||
"should have a quick create element in the first column");
|
||||
assert.strictEqual($quickCreate.find('.o_form_view.o_xxs_form_view').length, 1,
|
||||
"should have rendered an XXS form view");
|
||||
assert.containsOnce(kanban, '.o_cp_controller', 'should not have instantiated an extra control panel');
|
||||
assert.strictEqual($quickCreate.find('input').length, 2,
|
||||
"should have two inputs");
|
||||
assert.strictEqual($quickCreate.find('.o_field_widget').length, 3,
|
||||
|
||||
Reference in New Issue
Block a user