diff --git a/odex25_base/am_sar_symbol/static/src/css/style.css b/odex25_base/am_sar_symbol/static/src/css/style.css index 1b1564e4b..5bf755d72 100644 --- a/odex25_base/am_sar_symbol/static/src/css/style.css +++ b/odex25_base/am_sar_symbol/static/src/css/style.css @@ -1,4 +1,15 @@ -/* SAR Symbol Font Definition */ +@font-face { + font-family: 'Tajawal-Regular'; + src: url('../fonts/Tajawal-Regular.eot'); + src: url('../fonts/Tajawal-Regular.eot?#iefix') format('embedded-opentype'), + url('../fonts/Tajawal-Regular.woff2') format('woff2'), + url('../fonts/Tajawal-Regular.woff') format('woff'), + url('../fonts/Tajawal-Regular.ttf') format('truetype'); + font-weight: normal; + font-style: normal; + font-display: swap; +} + @font-face { font-family: 'sar-symbol'; src: url('../fonts/sar-symbol.eot?ebwrxj'); @@ -11,189 +22,53 @@ font-display: block; } -/* إزالة التطبيق العام للفونت - هذا السبب في المشكلة الأصلية */ -/* - هذا السطر كان يغير فونت النظام كله: - *:not(.fa):not(.oi) { - font-family: 'Tajawal-Regular', 'sar-symbol', sans-serif !important; - } - تم حذفه نهائياً -*/ - -/* ========================================== - الحل الصحيح: تطبيق الفونت بشكل انتقائي - ========================================== */ - -/* 1. تعريف كلاس خاص لرمز العملة السعودية */ -.sar_currency_symbol, -.saudi_riyal_symbol, -[data-currency="SAR"], -[data-currency-code="SAR"] { - font-family: 'sar-symbol', inherit, sans-serif !important; -} - -/* 2. تطبيق على الحقول النقدية المحددة */ -.o_field_monetary.sar_currency, -.o_field_monetary[data-currency="SAR"], -.oe_currency_value.sar_currency { - font-family: 'sar-symbol', inherit, sans-serif !important; -} - -/* 3. تطبيق على عناصر القوائم والجداول */ -.o_list_view .sar_currency, -.o_list_table .sar_currency, -table.o_list_table td.sar_currency { - font-family: 'sar-symbol', inherit, sans-serif !important; -} - -/* 4. تطبيق على عروض kanban */ -.o_kanban_view .sar_currency, -.oe_kanban_details .sar_currency { - font-family: 'sar-symbol', inherit, sans-serif !important; -} - -/* 5. التقارير المحاسبية */ -.o_account_reports_table .sar_currency, -.o_account_report_line .sar_currency, -.account_report .sar_currency { - font-family: 'sar-symbol', inherit, sans-serif !important; -} - -/* 6. نقطة البيع */ -.pos-content .sar_currency, -.o_pos_order_line .sar_currency, -.pos-receipt .sar_currency { - font-family: 'sar-symbol', inherit, sans-serif !important; -} - -/* 7. الفواتير والتقارير المطبوعة */ -.o_report_layout_standard .sar_currency, -.o_report_layout_boxed .sar_currency, -.report .sar_currency { - font-family: 'sar-symbol', inherit, sans-serif !important; -} - -/* 8. قوائم الأسعار */ -.product_price.sar_currency, -.pricelist .sar_currency { - font-family: 'sar-symbol', inherit, sans-serif !important; -} - -/* 9. الحقول المحسوبة والمجاميع */ -.o_form_view .o_group .sar_currency, -.oe_subtotal_footer .sar_currency { - font-family: 'sar-symbol', inherit, sans-serif !important; -} - -/* 10. تطبيق خاص للطباعة */ -@media print { - .sar_currency, - [data-currency="SAR"], - .saudi_riyal_symbol { - font-family: 'sar-symbol', inherit, sans-serif !important; - } -} - -/* 11. حقول البحث والفلاتر */ -.o_searchview .sar_currency, -.o_facet_values .sar_currency { - font-family: 'sar-symbol', inherit, sans-serif !important; -} - -/* 12. الويدجات المخصصة */ -.o_widget_monetary.sar_currency, -.monetary_field.sar_currency { - font-family: 'sar-symbol', inherit, sans-serif !important; -} - -/* 13. تحسين عرض الرمز */ -.sar_currency_symbol::before { +[class^="icon-sar"], [class*=" icon-sar"] { + /* use !important to prevent issues with browser extensions that change fonts */ font-family: 'sar-symbol' !important; - content: '\e900'; - margin-right: 3px; + /* Don't use speak property as it causes lint warnings */ + -webkit-font-feature-settings: 'liga'; + font-feature-settings: 'liga'; + font-style: normal; + font-weight: normal; + font-variant: normal; + text-transform: none; + line-height: 1; + + /* Better Font Rendering =========== */ + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; } -/* 14. للاستخدام اليدوي في القوالب */ -.manual_sar_symbol { - font-family: 'sar-symbol', inherit, sans-serif !important; +.icon-sar:before { + content: "\e900"; } -.manual_sar_symbol::before { +/* General font settings */ +*:not(.fa):not(.oi) { + font-family: 'Tajawal-Regular', 'sar-symbol', sans-serif !important; +} + +/* Report specific elements */ +.page, .header, .footer { + font-family: 'Tajawal-Regular', 'sar-symbol', sans-serif !important; +} + +/* Special class for SAR amount fields */ +.oe_currency_value::before, +.o_account_report_column_value::before, +.o_account_report_summary_value::before, +.o_account_report_line [data-parent-id] .o_account_report_column_value::before { content: '\e900'; font-family: 'sar-symbol' !important; - margin-right: 2px; + display: inline-block; + margin-right: 0; + visibility: hidden; + width: 0; } -/* ========================================== - JavaScript Helper Classes - هذه الكلاسات ستُطبق عبر JavaScript - ========================================== */ - -.js_has_sar_symbol { - font-family: 'sar-symbol', inherit, sans-serif !important; +body .o_content .o_account_reports_body .oe_currency_value::before, +body .o_content .o_account_reports_body .o_account_report_column_value::before, +body .o_content .o_account_reports_body .o_account_report_summary_value::before, +body .o_content .o_account_reports_body .o_account_report_line [data-parent-id] .o_account_report_column_value::before { + display: none; } - -.js_currency_sar { - font-family: 'sar-symbol', inherit, sans-serif !important; -} - -/* ========================================== - ضمان عدم تأثير على باقي النظام - ========================================== */ - -/* التأكد من أن باقي النصوص تحتفظ بالفونت الأصلي */ -body, -.o_form_view, -.o_list_view, -.o_kanban_view, -input:not(.sar_currency), -textarea:not(.sar_currency), -select:not(.sar_currency), -.o_field_widget:not(.sar_currency), -.btn:not(.sar_currency) { - /* الاحتفاظ بالفونت الأصلي */ -} - -/* ========================================== - CRITICAL: JavaScript Integration Required - ========================================== */ - -/* - هذا الحل يتطلب JavaScript للعمل بفعالية: - - 1. البحث عن العناصر التي تحتوي على رمز العملة السعودية - 2. إضافة كلاس 'sar_currency' أو 'js_has_sar_symbol' لها - 3. هذا سيضمن تطبيق الفونت الصحيح فقط على العناصر المطلوبة - - مثال JavaScript المطلوب: - - document.addEventListener('DOMContentLoaded', function() { - // البحث عن العناصر التي تحتوي على رمز الريال - const elements = document.querySelectorAll('*'); - elements.forEach(element => { - if (element.textContent && element.textContent.includes('﷼')) { - element.classList.add('js_has_sar_symbol'); - } - }); - - // مراقبة التغييرات في DOM - const observer = new MutationObserver(function(mutations) { - mutations.forEach(function(mutation) { - if (mutation.type === 'childList') { - mutation.addedNodes.forEach(function(node) { - if (node.nodeType === 1) { // Element node - if (node.textContent && node.textContent.includes('﷼')) { - node.classList.add('js_has_sar_symbol'); - } - } - }); - } - }); - }); - - observer.observe(document.body, { - childList: true, - subtree: true - }); - }); -*/ \ No newline at end of file diff --git a/odex25_base/am_sar_symbol/static/src/js/sar_symbol.js b/odex25_base/am_sar_symbol/static/src/js/sar_symbol.js deleted file mode 100644 index cc35264f8..000000000 --- a/odex25_base/am_sar_symbol/static/src/js/sar_symbol.js +++ /dev/null @@ -1,217 +0,0 @@ -/** - * SAR Symbol Detection and Font Application - * يقوم هذا الكود بالبحث عن رمز العملة السعودية وتطبيق الفونت المناسب - */ - -(function() { - 'use strict'; - - // رمز العملة السعودية الجديد - const SAR_SYMBOLS = [ - '﷼', // الرمز الكلاسيكي - 'ر.س', // اختصار ريال سعودي - 'SAR', // كود العملة - '\uFDFC', // Unicode للرمز الجديد - '\ue900' // الرمز المخصص في الفونت - ]; - - /** - * فحص ما إذا كان العنصر يحتوي على رمز العملة السعودية - */ - function containsSarSymbol(text) { - if (!text) return false; - return SAR_SYMBOLS.some(symbol => text.includes(symbol)); - } - - /** - * تطبيق كلاس الفونت على العنصر - */ - function applySarFont(element) { - if (element && element.nodeType === 1) { // Element node - element.classList.add('js_has_sar_symbol'); - - // تطبيق كلاسات إضافية حسب نوع العنصر - if (element.classList.contains('o_field_monetary')) { - element.classList.add('sar_currency'); - } - if (element.classList.contains('oe_currency_value')) { - element.classList.add('sar_currency'); - } - if (element.closest('.o_account_reports_table')) { - element.classList.add('sar_currency'); - } - } - } - - /** - * فحص عنصر واحد وأطفاله - */ - function checkElement(element) { - if (!element || element.nodeType !== 1) return; - - // فحص النص المباشر - if (element.textContent && containsSarSymbol(element.textContent)) { - applySarFont(element); - } - - // فحص الخصائص - const attributes = ['title', 'data-currency', 'data-currency-code', 'data-symbol']; - attributes.forEach(attr => { - const value = element.getAttribute(attr); - if (value && containsSarSymbol(value)) { - applySarFont(element); - } - }); - - // فحص الأطفال (فقط العناصر النصية المباشرة لتجنب الإفراط) - if (element.children.length === 0 && element.textContent) { - const parent = element.parentElement; - if (parent && containsSarSymbol(element.textContent)) { - applySarFont(parent); - } - } - } - - /** - * فحص جميع العناصر في الصفحة - */ - function scanAllElements() { - // فحص العناصر المحتملة أولاً (تحسين الأداء) - const potentialElements = [ - '.o_field_monetary', - '.oe_currency_value', - '.o_field_widget[data-field-type="monetary"]', - '.o_data_cell', - '.oe_kanban_details', - '.o_account_reports_table td', - '.o_account_reports_table th', - '.pos-content *', - '.product_price', - '[data-currency]', - '[data-currency-code]' - ]; - - potentialElements.forEach(selector => { - try { - const elements = document.querySelectorAll(selector); - elements.forEach(checkElement); - } catch (e) { - // تجاهل أخطاء السيلكتور - } - }); - - // فحص شامل كـ fallback - const allElements = document.querySelectorAll('*'); - allElements.forEach(element => { - if (element.textContent && element.textContent.length < 200) { // تجنب النصوص الطويلة - checkElement(element); - } - }); - } - - /** - * مراقب تغييرات DOM - */ - function setupDOMObserver() { - const observer = new MutationObserver(function(mutations) { - mutations.forEach(function(mutation) { - if (mutation.type === 'childList') { - mutation.addedNodes.forEach(function(node) { - if (node.nodeType === 1) { // Element node - checkElement(node); - // فحص الأطفال الجدد - const children = node.querySelectorAll('*'); - children.forEach(checkElement); - } - }); - } else if (mutation.type === 'characterData') { - // تغيير في النص - const parent = mutation.target.parentElement; - if (parent) { - checkElement(parent); - } - } - }); - }); - - observer.observe(document.body, { - childList: true, - subtree: true, - characterData: true - }); - - return observer; - } - - /** - * معالج خاص للحقول النقدية في أودو - */ - function handleOdooMonetaryFields() { - // مراقبة تحديثات البيانات في أودو - if (window.odoo && window.odoo.define) { - window.odoo.define('sar_symbol.field_utils', function (require) { - 'use strict'; - - const fieldUtils = require('web.field_utils'); - const originalFormatMonetary = fieldUtils.format.monetary; - - fieldUtils.format.monetary = function(value, field, options) { - const result = originalFormatMonetary.apply(this, arguments); - - // إذا كان النتيجة تحتوي على رمز العملة السعودية - if (result && containsSarSymbol(result)) { - // سنحتاج لمعالجة هذا في DOM لاحقاً - setTimeout(() => { - const elements = document.querySelectorAll('[data-field-type="monetary"]'); - elements.forEach(element => { - if (element.textContent && containsSarSymbol(element.textContent)) { - applySarFont(element); - } - }); - }, 100); - } - - return result; - }; - - return fieldUtils; - }); - } - } - - /** - * تهيئة النظام - */ - function initialize() { - console.log('SAR Symbol Font System: Initializing...'); - - // فحص أولي - scanAllElements(); - - // إعداد المراقبة - setupDOMObserver(); - - // معالجة خاصة لأودو - handleOdooMonetaryFields(); - - // فحص دوري (للتأكد) - setInterval(scanAllElements, 5000); - - console.log('SAR Symbol Font System: Ready'); - } - - // تشغيل النظام - if (document.readyState === 'loading') { - document.addEventListener('DOMContentLoaded', initialize); - } else { - initialize(); - } - - // تصدير للاستخدام الخارجي - window.SarSymbolSystem = { - scan: scanAllElements, - check: checkElement, - apply: applySarFont - }; - -})(); \ No newline at end of file diff --git a/odex25_base/am_sar_symbol/views/assets.xml b/odex25_base/am_sar_symbol/views/assets.xml index 91f38d6b4..ad00a9d73 100644 --- a/odex25_base/am_sar_symbol/views/assets.xml +++ b/odex25_base/am_sar_symbol/views/assets.xml @@ -1,87 +1,65 @@ - - - - - - + - -