Revision on https://github.com/odoo/odoo/commit/017e71322b6b7f0c232f0d66ba659a5972fc3534 Commit above correctly fixes an issue with 'Edit View: X' menu item in the debug manager, in which the name of the view was missing. To do so, it lets the controller be aware of the name of the view, so that it can be used in the template of the debug menu. However, we think there is a much better solution to fixing this issue: since the debug manager has knowledge of the view action, we can extend this object with the name of the view. This is exactly what this commit does: extend the action view object so that it knows the name of the view. That way, the template is much more readable, as `view.displayName` is more meaningful than `controller.viewName`. Task-ID 1878254
73 lines
2.2 KiB
JavaScript
73 lines
2.2 KiB
JavaScript
odoo.define('web.debugManagerTests', function (require) {
|
|
"use strict";
|
|
|
|
var DebugManager = require('web.DebugManager');
|
|
var testUtils = require('web.test_utils');
|
|
|
|
/**
|
|
* Create and return an instance of DebugManager with all rpcs going through a
|
|
* mock method, assuming that the user has access rights, and is an admin.
|
|
*
|
|
* @param {Object} [params={}]
|
|
*/
|
|
var createDebugManager = function (params) {
|
|
params = params || {};
|
|
_.extend(params, {
|
|
mockRPC: function (route, args) {
|
|
if (args.method === 'check_access_rights') {
|
|
return $.when(true);
|
|
}
|
|
if (args.method === 'xmlid_to_res_id') {
|
|
return $.when(true);
|
|
}
|
|
return this._super.apply(this, arguments);
|
|
},
|
|
session: {
|
|
user_has_group: function (group) {
|
|
if (group === 'base.group_no_one') {
|
|
return $.when(true);
|
|
}
|
|
return this._super.apply(this, arguments);
|
|
},
|
|
},
|
|
});
|
|
var debugManager = new DebugManager();
|
|
testUtils.addMockEnvironment(debugManager, params);
|
|
return debugManager;
|
|
};
|
|
|
|
QUnit.module('DebugManager', {}, function () {
|
|
|
|
QUnit.test("edit view menu item", function (assert) {
|
|
assert.expect(3);
|
|
|
|
var debugManager = createDebugManager();
|
|
|
|
debugManager.appendTo($('#qunit-fixture'));
|
|
|
|
// Simulate update debug manager from web client
|
|
var action = {
|
|
views: [{
|
|
displayName: "List",
|
|
fieldsView: {
|
|
view_id: 1,
|
|
},
|
|
type: "list",
|
|
}],
|
|
};
|
|
var view = {
|
|
viewType: "list",
|
|
};
|
|
debugManager.update('action', action, view);
|
|
|
|
var $editView = debugManager.$('a[data-action=edit][data-model="ir.ui.view"]');
|
|
assert.strictEqual($editView.length, 1, "should have edit view menu item");
|
|
assert.strictEqual($editView.text().trim(), "Edit View: List",
|
|
"should have correct menu item text for editing view");
|
|
assert.strictEqual($editView.data('id'), 1, "should have correct view_id");
|
|
|
|
debugManager.destroy();
|
|
});
|
|
});
|
|
});
|