Skip to content

Instantly share code, notes, and snippets.

@hsayed21
Last active May 28, 2025 02:10
Show Gist options
  • Select an option

  • Save hsayed21/bc7ed7bd581ee19cac91a0e32e2c735e to your computer and use it in GitHub Desktop.

Select an option

Save hsayed21/bc7ed7bd581ee19cac91a0e32e2c735e to your computer and use it in GitHub Desktop.
Hide Odoo Tickets Columns
// ==UserScript==
// @name Hide Odoo Tickets Columns
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Hide specific columns in Odoo helpdesk tickets table
// @author @hsayed21
// @match https://www.posbank.me/web*
// @match https://posbank.me/web*
// @icon https://www.google.com/s2/favicons?sz=64&domain=posbank.me
// @updateURL https://gist.github.com/hsayed21/bc7ed7bd581ee19cac91a0e32e2c735e.js
// @downloadURL https://gist.github.com/hsayed21/bc7ed7bd581ee19cac91a0e32e2c735e.js
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Available columns:
// 'id', 'display_name', 'team_id', 'ticket_problem_id', 'responsible_id',
// 'distributor_id', 'distributor_code', 'open_time_str', 'finish_date',
// 'close_date', 'activity_ids', 'sla_deadline', 'tag_ids', 'stage_id'
const COLUMNS_TO_HIDE = [
'team_id',
'distributor_code',
'open_time_str',
'close_date',
'finish_date'
];
function hideColumns() {
const table = document.querySelector('.o_list_table');
if (!table) {
return;
}
COLUMNS_TO_HIDE.forEach(columnName => {
const header = table.querySelector(`th[data-name="${columnName}"]`);
if (header) {
header.style.display = 'none';
}
const cells = table.querySelectorAll(`td[name="${columnName}"]`);
cells.forEach(cell => {
cell.style.display = 'none';
});
});
}
// Function to observe DOM changes and apply hiding when table is loaded
function observeTableChanges() {
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.type === 'childList') {
const addedNodes = mutation.addedNodes;
for (let i = 0; i < addedNodes.length; i++) {
const node = addedNodes[i];
if (node.nodeType === Node.ELEMENT_NODE) {
// Check if the added node contains a table or is a table
if (node.querySelector && (node.querySelector('.o_list_table') || node.classList.contains('o_list_table'))) {
setTimeout(hideColumns, 100); // Small delay to ensure DOM is ready
}
}
}
}
});
});
// Start observing
observer.observe(document.body, {
childList: true,
subtree: true
});
}
// Wait for the page to load
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', function() {
setTimeout(() => {
hideColumns();
observeTableChanges();
}, 1000);
});
} else {
setTimeout(() => {
hideColumns();
observeTableChanges();
}, 1000);
}
// Also run on page changes (for single page applications)
let lastUrl = location.href;
new MutationObserver(() => {
const url = location.href;
if (url !== lastUrl) {
lastUrl = url;
setTimeout(() => {
hideColumns();
}, 2000);
}
}).observe(document, { subtree: true, childList: true });
// Add some CSS to make hiding more robust
const style = document.createElement('style');
style.textContent = `
/* Hide columns more aggressively */
${COLUMNS_TO_HIDE.map(col => `
.o_list_table th[data-name="${col}"],
.o_list_table td[name="${col}"] {
display: none !important;
width: 0 !important;
min-width: 0 !important;
max-width: 0 !important;
padding: 0 !important;
margin: 0 !important;
border: none !important;
}
`).join('')}
`;
document.head.appendChild(style);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment