[SOLVED] remove duplicate on rendering
This commit is contained in:
parent
a5d618cc93
commit
8645f85905
|
|
@ -10,7 +10,7 @@ odoo.define('simplify_access_management.hide_export', function (require) {
|
|||
_render: function () {
|
||||
const res = this._super.apply(this, arguments);
|
||||
const self = this;
|
||||
this._super.apply(this, arguments);
|
||||
// this._super.apply(this, arguments);
|
||||
|
||||
var hash = window.location.hash.replace("#", '').split("&");
|
||||
let cids;
|
||||
|
|
@ -29,12 +29,30 @@ odoo.define('simplify_access_management.hide_export', function (require) {
|
|||
args: [cids, model]
|
||||
}).then(function (result) {
|
||||
if (result) {
|
||||
var btn1 = setInterval(function() {
|
||||
if ($('.o_list_export_xlsx').length) {
|
||||
$('.o_list_export_xlsx').remove();
|
||||
clearInterval(btn1);
|
||||
// dump code
|
||||
// var btn1 = setInterval(function () {
|
||||
// if ($('.o_list_export_xlsx').length) {
|
||||
// $('.o_list_export_xlsx').remove();
|
||||
// clearInterval(btn1);
|
||||
// }
|
||||
// }, 50);
|
||||
|
||||
// replace setInterval by MutationObserver
|
||||
// It reacts only when changes actually happen in the DOM
|
||||
// Cleaner logic and easier to control when disconnecting
|
||||
const observer = new MutationObserver(function (mutations, obs) {
|
||||
const exportBtn = document.querySelector('.o_list_export_xlsx');
|
||||
if (exportBtn) {
|
||||
exportBtn.remove();
|
||||
obs.disconnect(); // Stop observing once the button is removed
|
||||
}
|
||||
}, 50);
|
||||
});
|
||||
|
||||
// Start observing the body (or a more specific container)
|
||||
observer.observe(document.body, {
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue