summaryrefslogtreecommitdiff
path: root/addons/web/static
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-10-01 16:01:54 +0200
committerChristophe Simonis <chs@odoo.com>2018-10-01 16:01:54 +0200
commit43b63a04656276926dfecd65d3058d6464ee8ac5 (patch)
treed0f7c5b4a66540fa8422de2be928a30167e45eed /addons/web/static
parentb2870ae1ebc4d198c69142a2399827848d7d30b4 (diff)
parent57e387b645200756c29423af463afe001707f2ac (diff)
[MERGE] forward port branch saas-11.4 up to 57e387b6452
Diffstat (limited to 'addons/web/static')
-rw-r--r--addons/web/static/src/js/chrome/action_manager_act_window.js4
-rw-r--r--addons/web/static/src/js/chrome/keyboard_navigation_mixin.js7
-rw-r--r--addons/web/static/src/js/tools/debug_manager.js2
-rw-r--r--addons/web/static/tests/chrome/action_manager_tests.js37
-rw-r--r--addons/web/static/tests/helpers/test_utils.js4
-rw-r--r--addons/web/static/tests/tools/debug_manager_tests.js79
6 files changed, 131 insertions, 2 deletions
diff --git a/addons/web/static/src/js/chrome/action_manager_act_window.js b/addons/web/static/src/js/chrome/action_manager_act_window.js
index 2eacf6caa0d..d121ec929f0 100644
--- a/addons/web/static/src/js/chrome/action_manager_act_window.js
+++ b/addons/web/static/src/js/chrome/action_manager_act_window.js
@@ -340,7 +340,9 @@ ActionManager.include({
action.controllerID = controller.jsID;
return self._executeAction(action, options).done(function () {
if (lazyLoadedController) {
- self.controllerStack.unshift(lazyLoadedController.jsID);
+ // controller should be placed just before the current one
+ var index = self.controllerStack.length - 1;
+ self.controllerStack.splice(index, 0, lazyLoadedController.jsID);
self.controlPanel.update({
breadcrumbs: self._getBreadcrumbs(),
}, {clear: false});
diff --git a/addons/web/static/src/js/chrome/keyboard_navigation_mixin.js b/addons/web/static/src/js/chrome/keyboard_navigation_mixin.js
index a8d95d57a79..dc65d2ea610 100644
--- a/addons/web/static/src/js/chrome/keyboard_navigation_mixin.js
+++ b/addons/web/static/src/js/chrome/keyboard_navigation_mixin.js
@@ -144,6 +144,13 @@ odoo.define('web.KeyboardNavigationMixin', function (require) {
});
this._addAccessKeyOverlays();
}
+ // on mac, there are a number of keys that are only accessible though the usage of
+ // the ALT key (like the @ sign in most keyboards)
+ // for them we do not facilitate the access keys, so they will need to be activated classically
+ // though Control + Alt + key (case sensitive), see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/accesskey
+ if (this.BrowserDetection.isOsMac())
+ return;
+
if (keyDownEvent.altKey && !keyDownEvent.ctrlKey && keyDownEvent.key.length === 1) { // we don't want to catch the Alt key down, only the characters A to Z and number keys
var elementWithAccessKey = [];
if (keyDownEvent.keyCode >= 65 && keyDownEvent.keyCode <= 90 || keyDownEvent.keyCode >= 97 && keyDownEvent.keyCode <= 122) {
diff --git a/addons/web/static/src/js/tools/debug_manager.js b/addons/web/static/src/js/tools/debug_manager.js
index 6f6022b021f..391d8613aac 100644
--- a/addons/web/static/src/js/tools/debug_manager.js
+++ b/addons/web/static/src/js/tools/debug_manager.js
@@ -504,7 +504,7 @@ DebugManager.include({
model: 'ir.default',
method: 'set',
args: [
- self._controller.fields_view.model,
+ self._action.res_model,
fieldToSet,
value,
selfUser,
diff --git a/addons/web/static/tests/chrome/action_manager_tests.js b/addons/web/static/tests/chrome/action_manager_tests.js
index 3b7477f4857..9233229a984 100644
--- a/addons/web/static/tests/chrome/action_manager_tests.js
+++ b/addons/web/static/tests/chrome/action_manager_tests.js
@@ -811,6 +811,43 @@ QUnit.module('ActionManager', {
actionManager.destroy();
});
+ QUnit.test('lazy load multi record view with previous action', function (assert) {
+ assert.expect(6);
+
+ var actionManager = createActionManager({
+ actions: this.actions,
+ archs: this.archs,
+ data: this.data,
+ debug: 1,
+ });
+ actionManager.doAction(4);
+
+ assert.strictEqual($('.o_control_panel .breadcrumb li').length, 1,
+ "there should be one controller in the breadcrumbs");
+ assert.strictEqual($('.o_control_panel .breadcrumb li').text(), 'Partners Action 4',
+ "breadcrumbs should contain the display_name of the opened record");
+
+ actionManager.doAction(3, {
+ resID: 2,
+ viewType: 'form',
+ });
+
+ assert.strictEqual($('.o_control_panel .breadcrumb li').length, 3,
+ "there should be three controllers in the breadcrumbs");
+ assert.strictEqual($('.o_control_panel .breadcrumb li').text(), 'Partners Action 4PartnersSecond record',
+ "the breadcrumb elements should be correctly ordered");
+
+ // go back to List
+ $('.o_control_panel .breadcrumb a:last').click();
+
+ assert.strictEqual($('.o_control_panel .breadcrumb li').length, 2,
+ "there should be two controllers in the breadcrumbs");
+ assert.strictEqual($('.o_control_panel .breadcrumb li').text(), 'Partners Action 4Partners',
+ "the breadcrumb elements should be correctly ordered");
+
+ actionManager.destroy();
+ });
+
QUnit.test('change the viewType of the current action', function (assert) {
assert.expect(13);
diff --git a/addons/web/static/tests/helpers/test_utils.js b/addons/web/static/tests/helpers/test_utils.js
index 44763bc42b9..6594b274be1 100644
--- a/addons/web/static/tests/helpers/test_utils.js
+++ b/addons/web/static/tests/helpers/test_utils.js
@@ -125,6 +125,7 @@ var createActionManager = function (params) {
*/
var createDebugManager = function (params) {
params = params || {};
+ var mockRPC = params.mockRPC;
_.extend(params, {
mockRPC: function (route, args) {
if (args.method === 'check_access_rights') {
@@ -133,6 +134,9 @@ var createDebugManager = function (params) {
if (args.method === 'xmlid_to_res_id') {
return $.when(true);
}
+ if (mockRPC) {
+ return mockRPC.apply(this, arguments);
+ }
return this._super.apply(this, arguments);
},
session: {
diff --git a/addons/web/static/tests/tools/debug_manager_tests.js b/addons/web/static/tests/tools/debug_manager_tests.js
index 8e41481734f..a52ad9e9c65 100644
--- a/addons/web/static/tests/tools/debug_manager_tests.js
+++ b/addons/web/static/tests/tools/debug_manager_tests.js
@@ -84,5 +84,84 @@ QUnit.module('DebugManager', {}, function () {
debugManager.destroy();
});
+
+ QUnit.test("Debug: Set defaults with right model", function (assert) {
+ assert.expect(2);
+
+ /* Click on debug > set default,
+ * set some defaults, click on save
+ * model and some other data should be sent to server
+ */
+
+ // We'll need a full blown architecture with some data
+ var data = {
+ partner: {
+ fields: {
+ foo: {string: "Foo", type: "char", default: "My little Foo Value"},
+ },
+ records: [{
+ id: 1,
+ foo: "yop",
+ }]
+ },
+ 'ir.default': { // We just need this to be defined
+ fields: {},
+ },
+ }
+
+ var form = testUtils.createView({
+ View: FormView,
+ model: 'partner',
+ data: data,
+ arch: '<form string="Partners">' +
+ '<field name="foo" />' +
+ '</form>',
+ res_id: 1,
+ });
+
+ // Now the real tested component
+ var debugManager = createDebugManager({
+ data: data,
+ mockRPC: function (route, args) {
+ if (route == "/web/dataset/call_kw/ir.default/set") {
+ assert.deepEqual(args.args, ["partner", "foo", "yop", true, true, false],
+ 'Model, field, value and booleans for current user/company should have been passed');
+ return $.when();
+ }
+ return this._super.apply(this, arguments);
+ }
+ });
+
+ debugManager.appendTo($('#qunit-fixture'));
+
+ // Simulate update debug manager from web client
+ var action = {
+ views: [{
+ fieldsView: {
+ view_id: 1,
+ model: 'partner',
+ type: 'form',
+ },
+ type: "form",
+ }],
+ res_model: 'partner',
+ };
+
+ // We are all set
+ debugManager.update('action', action, form);
+
+ // click on set_defaults dropdown
+ debugManager.$('a[data-action="set_defaults"]').click();
+ var $modal = $('.modal-content');
+ assert.strictEqual($modal.length, 1, 'One modal present');
+
+ $modal.find('select[id=formview_default_fields] option[value=foo]').prop('selected', true);
+
+ // Save
+ $modal.find('.modal-footer button').eq(1).click();
+
+ form.destroy();
+ debugManager.destroy();
+ });
});
});