diff --git a/static/src/views/inventory_decimal_patch.js b/static/src/views/inventory_decimal_patch.js index 3d7dbff..4dc10c3 100644 --- a/static/src/views/inventory_decimal_patch.js +++ b/static/src/views/inventory_decimal_patch.js @@ -6,73 +6,76 @@ import { ListRenderer } from "@web/views/list/list_renderer"; console.log('Loading inventory decimal patch...'); // Safe DOM manipulation approach to avoid Owl lifecycle conflicts -patch(ListRenderer.prototype, { - async render() { - const result = await super.render(); - - // Schedule decimal styling after Owl completes its rendering cycle - this.scheduleDecimalStyling(); - - return result; - }, +// Safe DOM manipulation approach to avoid Owl lifecycle conflicts +// patch(ListRenderer.prototype, { +// async render() { +// const result = await super.render(); - scheduleDecimalStyling() { - // Use requestAnimationFrame to ensure we run after Owl's DOM updates - requestAnimationFrame(() => { - try { - this.applyDecimalStyling(); - } catch (error) { - console.warn('Decimal styling error (non-critical):', error); - } - }); - }, +// // Schedule decimal styling after Owl completes its rendering cycle +// this.scheduleDecimalStyling(); - applyDecimalStyling() { - if (!this.el || !document.contains(this.el)) return; - - // Find all cells in the list table, but be more careful about DOM manipulation - const cells = this.el.querySelectorAll('td:not([data-decimal-processed]), .o_data_cell:not([data-decimal-processed])'); - - cells.forEach(cell => { - try { - // Skip if cell is being updated by Owl - if (cell.hasAttribute('data-owl-updating')) return; - - // Mark as processed to avoid double processing - cell.setAttribute('data-decimal-processed', 'true'); - - const text = cell.textContent?.trim(); - if (!text) return; - - // Check for decimal numbers (including currency) - const decimalMatch = text.match(/^(.*)(\d+)([.,])(\d+)(.*)$/); - if (decimalMatch) { - const [, prefix, integerPart, decimalPoint, decimalPart, suffix] = decimalMatch; - - console.log('Applying safe DOM decimal styling to:', text); - - // Create new HTML structure safely - const newHTML = `${prefix}${integerPart}${decimalPoint}${decimalPart}${suffix}`; - - // Only update if the content hasn't changed - if (cell.textContent.trim() === text) { - cell.innerHTML = newHTML; - } - } - // Handle whole numbers by adding .000 - else if (text.match(/^\d+$/) && text.length > 0) { - console.log('Adding decimals to whole number safely:', text); - - // Only update if the content hasn't changed - if (cell.textContent.trim() === text) { - cell.innerHTML = `${text}.000`; - } - } - } catch (error) { - console.warn('Error processing cell (non-critical):', error); - } - }); - } -}); +// return result; +// }, + + +// scheduleDecimalStyling() { +// // Use requestAnimationFrame to ensure we run after Owl's DOM updates +// requestAnimationFrame(() => { +// try { +// this.applyDecimalStyling(); +// } catch (error) { +// console.warn('Decimal styling error (non-critical):', error); +// } +// }); +// }, + + +// applyDecimalStyling() { +// if (!this.el || !document.contains(this.el)) return; + +// // Find all cells in the list table, but be more careful about DOM manipulation +// const cells = this.el.querySelectorAll('td:not([data-decimal-processed]), .o_data_cell:not([data-decimal-processed])'); + +// cells.forEach(cell => { +// try { +// // Skip if cell is being updated by Owl +// if (cell.hasAttribute('data-owl-updating')) return; + +// // Mark as processed to avoid double processing +// cell.setAttribute('data-decimal-processed', 'true'); + +// const text = cell.textContent?.trim(); +// if (!text) return; + +// // Check for decimal numbers (including currency) +// const decimalMatch = text.match(/^(.*)(\d+)([.,])(\d+)(.*)$/); +// if (decimalMatch) { +// const [, prefix, integerPart, decimalPoint, decimalPart, suffix] = decimalMatch; + +// console.log('Applying safe DOM decimal styling to:', text); + +// // Create new HTML structure safely +// const newHTML = `${prefix}${integerPart}${decimalPoint}${decimalPart}${suffix}`; + +// // Only update if the content hasn't changed +// if (cell.textContent.trim() === text) { +// // cell.innerHTML = newHTML; +// } +// } +// // Handle whole numbers by adding .000 +// else if (text.match(/^\d+$/) && text.length > 0) { +// console.log('Adding decimals to whole number safely:', text); + +// // Only update if the content hasn't changed +// if (cell.textContent.trim() === text) { +// // cell.innerHTML = `${text}.000`; +// } +// } +// } catch (error) { +// console.warn('Error processing cell (non-critical):', error); +// } +// }); +// } +// }); console.log('Inventory decimal patch loaded'); \ No newline at end of file