fix for odoo 19

This commit is contained in:
Suherdy Yacob 2026-01-23 14:31:34 +07:00
parent 6d0c445279
commit 80930a9535

View File

@ -35,11 +35,11 @@ function safelyApplyDecimalStyling(element) {
// Improved patterns that properly distinguish thousands separators from decimal separators
const patterns = [
// Currency with decimal: Rp 6,210,000.00 (comma for thousands, dot for decimal)
/^(.*Rp\s*)(\d{1,3}(?:,\d{3})*)\.(\d{2})(.*)$/,
// Standard decimal with thousands: 1,234.56 (comma for thousands, dot for decimal)
/^(.*)(\d{1,3}(?:,\d{3})*)\.(\d+)(.*)$/,
// Simple decimal without thousands: 240.000, 123.45
/^(.*)(\d+)\.(\d+)(.*)$/
/^(.*Rp[\s\u00A0]*)(\d[\d,\s\u00A0]*)\.(\d{2})(.*)$/,
// Generic decimal with thousand separators (dot as decimal)
/^(.*?)([\d,\s\u00A0]*\d)\.(\d+)(.*)$/,
// Simple decimal
/^(.*?)(\d+)\.(\d+)(.*)$/
];
for (const pattern of patterns) {
@ -47,12 +47,15 @@ function safelyApplyDecimalStyling(element) {
if (match) {
const [, prefix, integerPart, decimalPart, suffix] = match;
console.log('Ultra-Safe Decimal Observer: Styling decimal number', text);
// console.log('Ultra-Safe Decimal Observer: MATCH FOUND', {text, prefix, integerPart, decimalPart, suffix});
// Triple-check the element is safe to modify
// For tfoot, we are more permissive because they are always readonly
if (element.textContent.trim() === text &&
document.contains(element) &&
!element.closest('.o_field_widget:not(.o_readonly_modifier)')) {
(!element.closest('.o_field_widget:not(.o_readonly_modifier)') || element.closest('tfoot'))) {
console.log('Ultra-Safe Decimal Observer: STYLING', text, element.tagName, element.className);
const newHTML = `${prefix || ''}${integerPart}<span class="o_decimal">.${decimalPart}</span>${suffix || ''}`;
element.innerHTML = newHTML;
return true;
@ -100,11 +103,16 @@ function ultraSafelyProcessContainer(container) {
if (!container || !document.contains(container)) return;
try {
// Only process elements in readonly contexts to avoid editable field conflicts
const elements = container.querySelectorAll('.o_readonly_modifier td:not([data-decimal-processed]), .o_readonly_modifier span:not([data-decimal-processed]), .o_field_monetary.o_readonly_modifier:not([data-decimal-processed]), .o_field_float.o_readonly_modifier:not([data-decimal-processed])');
// Select elements likely to contain formatted decimals in readonly contexts or footers
const elements = container.querySelectorAll('.o_readonly_modifier td:not([data-decimal-processed]), .o_readonly_modifier span:not([data-decimal-processed]), tfoot td:not([data-decimal-processed]), tfoot span:not([data-decimal-processed]), .o_list_number:not([data-decimal-processed])');
elements.forEach(element => {
// Only process leaf elements in readonly contexts
// Optimization: If a TD has a SPAN, we prefer to style the SPAN to preserve tooltips
if (element.tagName === 'TD' && element.querySelector('span')) {
return;
}
// Only process leaf elements or elements with very simple structures
if ((element.children.length === 0 ||
(element.children.length === 1 && element.children[0].tagName === 'SPAN')) &&
!element.hasAttribute('data-owl-updating') &&