Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ODOO-411 Background open records in new tab #19

Open
wants to merge 2 commits into
base: 15.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions addons/web/static/src/legacy/js/views/list/list_renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,46 @@ var ListRenderer = BasicRenderer.extend({
$tr.addClass('o_list_no_open');
}
this._setDecorationClasses($tr, this.rowDecorations, record);
/**
* If the record is allowed to be opened and the current view is a list
* view (not a list embedded in a form view), add event listeners for
* Ctrl+Click and Middle Click to open the record in a new tab.
*/
if (!$tr.hasClass('o_list_no_open')) {
$tr.mousedown(function(ev) {
var startURI;
var endURI;
var baseURI = $tr[0].baseURI;

switch(ev.originalEvent.which) {
case 1:
if (ev.ctrlKey || ev.metaKey && baseURI.substring(baseURI.length - 4) === "list") {
// Prevent record from being opened in current tab
ev.preventDefault();
// Construct form URL for selected record
[startURI, endURI] = baseURI.split("#");
window.open(
startURI + "#id=" + record.res_id + "&" +
endURI.substring(0, endURI.length - 4) + "form",
"_blank"
);
}
break;
case 2:
if (baseURI.substring(baseURI.length - 4) === "list") {
// Construct form URL for selected record
[startURI, endURI] = baseURI.split("#");
window.open(
startURI + "#id=" + record.res_id + "&" +
endURI.substring(0, endURI.length - 4) + "form",
"_blank"
);
}
break;
}
return true;
})
}
return $tr;
},
/**
Expand Down