[IMP] mail, web: attachments & messages in debug actions.
- added two new actions to the form view debug action list, both opens list (+ form) views of messages and attachments respectively for which the domain is restricted to the current record. task: 1860031
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
odoo.define('mail.DebugManager', function (require) {
|
||||
"use strict";
|
||||
|
||||
var core = require('web.core');
|
||||
var DebugManager = require('web.DebugManager');
|
||||
|
||||
var _t = core._t;
|
||||
/**
|
||||
* adds a new method available for the debug manager, called by the "Manage Messages" button.
|
||||
*
|
||||
*/
|
||||
DebugManager.include({
|
||||
getMailMessages: function () {
|
||||
var self = this;
|
||||
var selectedIDs = this._controller.getSelectedIds();
|
||||
if (!selectedIDs.length) {
|
||||
console.warn(_t("No message available"));
|
||||
return;
|
||||
}
|
||||
this.do_action({
|
||||
res_model: 'mail.message',
|
||||
name: _t('Manage Messages'),
|
||||
views: [[false, 'list'], [false, 'form']],
|
||||
type: 'ir.actions.act_window',
|
||||
domain: [['res_id', '=', selectedIDs[0]], ['model', '=', this._controller.modelName]],
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,6 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<!--
|
||||
extends the debug mode menu to allow access to the attachment list view of the current record.
|
||||
-->
|
||||
<t t-extend="WebClient.DebugManager.View">
|
||||
<t t-jquery="a[data-action='get_metadata']" t-operation="after">
|
||||
<a role="menuitem" href="#" data-action="getMailMessages" class="dropdown-item">Manage Messages</a>
|
||||
</t>
|
||||
</t>
|
||||
<!--
|
||||
@param {mail.model.AbstractThread} thread
|
||||
@param {Object} options
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
odoo.define('mail.debugManagerTests', function (require) {
|
||||
"use strict";
|
||||
|
||||
var testUtils = require('web.test_utils');
|
||||
|
||||
var createDebugManager = testUtils.createDebugManager;
|
||||
|
||||
QUnit.module('Mail DebugManager', {}, function () {
|
||||
|
||||
QUnit.test("Manage Messages", function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
var debugManager = createDebugManager({
|
||||
intercepts: {
|
||||
do_action: function (event) {
|
||||
assert.deepEqual(event.data.action, {
|
||||
res_model: 'mail.message',
|
||||
name: "Manage Messages",
|
||||
views: [[false, 'list'], [false, 'form']],
|
||||
type: 'ir.actions.act_window',
|
||||
domain: [['res_id', '=', 5], ['model', '=', 'testModel']],
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
debugManager.appendTo($('#qunit-fixture'));
|
||||
|
||||
// Simulate update debug manager from web client
|
||||
var action = {
|
||||
views: [{
|
||||
displayName: "Form",
|
||||
fieldsView: {
|
||||
view_id: 1,
|
||||
},
|
||||
type: "form",
|
||||
}],
|
||||
};
|
||||
var view = {
|
||||
viewType: "form",
|
||||
getSelectedIds: function () {
|
||||
return [5];
|
||||
},
|
||||
modelName: 'testModel',
|
||||
};
|
||||
debugManager.update('action', action, view);
|
||||
|
||||
var $messageMenu = debugManager.$('a[data-action=getMailMessages]');
|
||||
assert.strictEqual($messageMenu.length, 1, "should have Manage Message menu item");
|
||||
assert.strictEqual($messageMenu.text().trim(), "Manage Messages",
|
||||
"should have correct menu item text");
|
||||
$messageMenu.click();
|
||||
|
||||
debugManager.destroy();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -65,6 +65,8 @@
|
||||
<script type="text/javascript" src="/mail/static/src/js/systray/systray_activity_menu.js"></script>
|
||||
<script type="text/javascript" src="/mail/static/src/js/systray/systray_messaging_menu.js"></script>
|
||||
<script type="text/javascript" src="/mail/static/src/js/tour.js"></script>
|
||||
<!-- tools -->
|
||||
<script type="text/javascript" src="/mail/static/src/js/tools/debug_manager.js"></script>
|
||||
<!-- utils -->
|
||||
<script type="text/javascript" src="/mail/static/src/js/utils.js"></script>
|
||||
<script type="text/javascript" src="/mail/static/src/js/activity.js"></script>
|
||||
@@ -118,6 +120,8 @@
|
||||
<script type="text/javascript" src="/mail/static/tests/systray/systray_messaging_menu_mail_failure_tests.js"></script>
|
||||
<script type="text/javascript" src="/mail/static/tests/discuss_moderation_tests.js"></script>
|
||||
<script type="text/javascript" src="/mail/static/tests/discuss_typing_notification_tests.js"></script>
|
||||
<!-- tools -->
|
||||
<script type="text/javascript" src="/mail/static/tests/tools/debug_manager_tests.js"></script>
|
||||
<!-- models -->
|
||||
<script type="text/javascript" src="/mail/static/tests/models/cc_throttle_function_tests.js"></script>
|
||||
<script type="text/javascript" src="/mail/static/tests/models/timer_tests.js"></script>
|
||||
|
||||
@@ -353,7 +353,20 @@ DebugManager.include({
|
||||
}));
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
get_attachments: function() {
|
||||
var selectedIDs = this._controller.getSelectedIds();
|
||||
if (!selectedIDs.length) {
|
||||
console.warn(_t("No attachment available"));
|
||||
return;
|
||||
}
|
||||
this.do_action({
|
||||
res_model: 'ir.attachment',
|
||||
name: _t('Manage Attachments'),
|
||||
views: [[false, 'list'], [false, 'form']],
|
||||
type: 'ir.actions.act_window',
|
||||
domain: [['res_model', '=', this._action.res_model], ['res_id', '=', selectedIDs[0]]],
|
||||
});
|
||||
},
|
||||
get_metadata: function() {
|
||||
var self = this;
|
||||
var selectedIDs = this._controller.getSelectedIds();
|
||||
|
||||
@@ -267,6 +267,7 @@
|
||||
<a role="menuitem" href="#" data-action="set_defaults" class="dropdown-item">Set Defaults</a>
|
||||
<t t-if="controller.getSelectedIds().length === 1">
|
||||
<a role="menuitem" href="#" data-action="get_metadata" class="dropdown-item">View Metadata</a>
|
||||
<a role="menuitem" href="#" data-action="get_attachments" class="dropdown-item">Manage Attachments</a>
|
||||
</t>
|
||||
</t>
|
||||
<a role="menuitem" href="#" data-action="fvg" class="dropdown-item">Fields View Get</a>
|
||||
|
||||
@@ -16,6 +16,7 @@ var basic_fields = require('web.basic_fields');
|
||||
var config = require('web.config');
|
||||
var ControlPanel = require('web.ControlPanel');
|
||||
var core = require('web.core');
|
||||
var DebugManager = require('web.DebugManager');
|
||||
var dom = require('web.dom');
|
||||
var session = require('web.session');
|
||||
var MockServer = require('web.MockServer');
|
||||
@@ -116,6 +117,37 @@ var createActionManager = function (params) {
|
||||
|
||||
return actionManager;
|
||||
};
|
||||
/**
|
||||
* 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();
|
||||
addMockEnvironment(debugManager, params);
|
||||
return debugManager;
|
||||
};
|
||||
|
||||
/**
|
||||
* performs a fields_view_get, and mocks the postprocessing done by the
|
||||
@@ -869,6 +901,7 @@ return $.when(
|
||||
return {
|
||||
addMockEnvironment: addMockEnvironment,
|
||||
createActionManager: createActionManager,
|
||||
createDebugManager: createDebugManager,
|
||||
createAsyncView: createAsyncView,
|
||||
createModel: createModel,
|
||||
createParent: createParent,
|
||||
|
||||
@@ -1,44 +1,13 @@
|
||||
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;
|
||||
};
|
||||
var createDebugManager = testUtils.createDebugManager;
|
||||
|
||||
QUnit.module('DebugManager', {}, function () {
|
||||
|
||||
QUnit.test("edit view menu item", function (assert) {
|
||||
QUnit.test("list: edit view menu item", function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
var debugManager = createDebugManager();
|
||||
@@ -68,5 +37,52 @@ QUnit.module('DebugManager', {}, function () {
|
||||
|
||||
debugManager.destroy();
|
||||
});
|
||||
|
||||
QUnit.test("form: Manage Attachments option", function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
var debugManager = createDebugManager({
|
||||
intercepts: {
|
||||
do_action: function (event) {
|
||||
assert.deepEqual(event.data.action, {
|
||||
domain: [["res_model", "=", "test.model"],["res_id", "=", 5]],
|
||||
name: "Manage Attachments",
|
||||
res_model: "ir.attachment",
|
||||
type: "ir.actions.act_window",
|
||||
views: [[false, "list"],[false, "form"]],
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
debugManager.appendTo($('#qunit-fixture'));
|
||||
|
||||
// Simulate update debug manager from web client
|
||||
var action = {
|
||||
views: [{
|
||||
displayName: "Form",
|
||||
fieldsView: {
|
||||
view_id: 2,
|
||||
},
|
||||
type: "form",
|
||||
}],
|
||||
res_model: "test.model",
|
||||
};
|
||||
var view = {
|
||||
viewType: "form",
|
||||
getSelectedIds: function () {
|
||||
return [5];
|
||||
},
|
||||
};
|
||||
debugManager.update('action', action, view);
|
||||
|
||||
var $attachmentMenu = debugManager.$('a[data-action=get_attachments]');
|
||||
assert.strictEqual($attachmentMenu.length, 1, "should have Manage Attachments menu item");
|
||||
assert.strictEqual($attachmentMenu.text().trim(), "Manage Attachments",
|
||||
"should have correct menu item text");
|
||||
$attachmentMenu.click();
|
||||
|
||||
debugManager.destroy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user