From 0d5b18e5ae44e2cf6e2a09b8046fcec02b2191f8 Mon Sep 17 00:00:00 2001 From: Mohamed Eltayar <152964073+maltayyar2@users.noreply.github.com> Date: Thu, 28 Aug 2025 17:54:09 +0300 Subject: [PATCH] Revert "hijri_date_enhance" --- odex25_base/web_hijri_datepicker/README.md | 369 ++++------- .../web_hijri_datepicker/__manifest__.py | 140 ++-- .../static/src/js/web_hijri_date.js | 608 ++++-------------- .../static/src/scss/hijri_modern.css | 443 +++++-------- .../static/src/scss/web_hijri_date.scss | 539 +--------------- .../static/src/xml/web_hijri_date.xml | 99 +-- .../views/web_hijri_template.xml | 156 +---- 7 files changed, 500 insertions(+), 1854 deletions(-) diff --git a/odex25_base/web_hijri_datepicker/README.md b/odex25_base/web_hijri_datepicker/README.md index d53c0639a..7934c205a 100644 --- a/odex25_base/web_hijri_datepicker/README.md +++ b/odex25_base/web_hijri_datepicker/README.md @@ -1,298 +1,151 @@ -# Enhanced Web Hijri Datepicker for Odoo 14 +# Web Hijri Datepicker - Enhanced Version 2.2.0 - - - - +## 🌟 التحديثات الجديدة -## 🎯 Perfect Integration with Odoo 14 Standard Datepicker +### ✨ المميزات المحسنة: +- **مكتبة محدثة**: ترقية إلى jQuery Calendars v2.2.0 +- **تصميم حديث**: واجهة مستخدم محسنة تتماشى مع Odoo +- **أداء أفضل**: تحسينات في السرعة والاستجابة +- **دعم RTL محسن**: دعم أفضل للغة العربية +- **UX محسن**: تجربة مستخدم أكثر سلاسة -This enhanced version provides **seamless Hijri calendar integration** that perfectly matches Odoo's standard datepicker appearance and behavior while maintaining all Islamic calendar functionality. +### 🎨 التصميم الجديد: +- شكل عصري ومتجاوب +- ألوان متناسقة مع Odoo +- تأثيرات بصرية ناعمة +- أيقونات وأزرار محسنة +- انتقالات سلسة -## ✨ What's New in v2.3.0 +### 🚀 التحسينات التقنية: +- معالجة أخطاء محسنة +- أداء أفضل للذاكرة +- تكامل أفضل مع Odoo +- دعم التحقق من البيانات +- تحسين الأمان -### 🎨 **Visual Excellence** -- **Pixel-Perfect Integration**: Matches Odoo 14 datepicker appearance exactly -- **Bootstrap 4 Compatible**: Uses same CSS framework and styling as Odoo -- **Consistent Z-index**: Proper layering (1051) matching Odoo's modal system -- **Standard Dimensions**: 22rem width (352px) - same as Odoo datepicker -- **Unified Color Scheme**: Uses Odoo's exact color variables and themes +## 📦 المتطلبات -### ⚡ **Performance Improvements** -- **40% Faster Loading**: Optimized asset loading and initialization -- **25% Reduced Memory Usage**: Efficient resource management -- **Sub-200ms Initialization**: Lightning-fast startup time -- **<1ms Conversion Speed**: Instant Gregorian ↔ Hijri conversion +- Odoo 14.0+ +- jQuery 3.0+ +- متصفح حديث (Chrome 60+, Firefox 55+, Safari 10+) -### 🛠️ **Technical Excellence** -- **Enhanced Error Handling**: Robust validation and conversion mechanisms -- **Memory Management**: Proper cleanup and resource management -- **Cross-browser Compatibility**: Works on all modern browsers -- **Accessibility**: Screen reader support and keyboard navigation +## 🔧 التثبيت -## 🌟 Key Features +1. تثبيت الموديول عبر Odoo Apps +2. إعادة تشغيل الخدمة (اختياري للأداء الأمثل) +3. تحديث assets إذا لزم الأمر -### **Dual Calendar System** -- **Side-by-Side Display**: Gregorian and Hijri dates displayed together -- **Automatic Synchronization**: Real-time conversion between calendars -- **Smart Input Handling**: Click either field to select dates +## 📱 الاستخدام -### **Perfect Odoo Integration** -- **Form Views**: Enhanced date fields with elegant Hijri display -- **List Views**: Inline editing with dual calendar support -- **Readonly Mode**: Beautiful Hijri date display in readonly fields -- **Search Integration**: Compatible with date range filters +سيظهر حقل التاريخ الهجري تلقائياً أسفل كل حقل تاريخ ميلادي في النظام. -### **Islamic Calendar Features** -- **Accurate Conversions**: Precise Islamic calendar calculations -- **Arabic Numerals**: Proper Arabic-Indic numeral display (٠١٢٣...) -- **Month Names**: Traditional Arabic month names with diacritics -- **RTL Support**: Full right-to-left text support -- **Multiple Variants**: Support for different Islamic calendar systems +### المميزات: +- **تحويل تلقائي**: بين التاريخ الميلادي والهجري +- **مزامنة فورية**: تحديث الحقلين معاً +- **واجهة بديهية**: سهلة الاستخدام +- **دعم كامل للعربية**: أرقام وأسماء الشهور بالعربية -### **User Experience** -- **Intelligent Positioning**: Smart popup placement avoiding viewport edges -- **Responsive Design**: Works perfectly on all screen sizes -- **Touch Friendly**: Optimized for mobile and tablet devices -- **Keyboard Navigation**: Full accessibility support +## 🌍 اللغات المدعومة -## 📸 Screenshots +- العربية (افتراضي) +- الإنجليزية +- الفارسية -### Form View Integration -The Hijri datepicker seamlessly integrates with Odoo's form views, providing dual calendar functionality without disrupting the standard UI. +## 🎯 الميزات الرئيسية -### List View Support -Inline editing in list views maintains the dual calendar functionality while preserving Odoo's standard appearance. +### ✅ للمستخدمين: +- واجهة بديهية وسهلة +- تحويل فوري بين التقاويم +- عرض واضح للتواريخ +- دعم شامل للعربية -### Popup Calendar -The Hijri calendar popup matches Odoo's standard datepicker styling exactly, ensuring a consistent user experience. +### ✅ للمطورين: +- كود نظيف ومنظم +- API مرن للتخصيص +- تكامل سلس مع Odoo +- موثق بالكامل -## 🚀 Installation +## 🔄 التحديثات من الإصدار السابق -### Method 1: Module Installation (Recommended) -1. Download or clone this module to your Odoo addons directory -2. Update your apps list in Odoo -3. Install "Enhanced Web Hijri Datepicker for Odoo 14" -4. All date fields will automatically gain Hijri functionality +### 🆕 جديد في v2.2.0: +1. **مكتبة jQuery Calendars محدثة** +2. **تصميم UI/UX جديد كلياً** +3. **أداء محسن بنسبة 40%** +4. **معالجة أخطاء متقدمة** +5. **دعم RTL محسن** +6. **تكامل أفضل مع النظام** -### Method 2: Git Clone -```bash -cd /path/to/your/odoo/addons -git clone https://github.com/your-repo/web_hijri_datepicker.git -``` +### 🐛 الإصلاحات: +- حل مشكلة التداخل في العرض +- تحسين الاستجابة على الأجهزة المحمولة +- إصلاح مشكلة عرض التواريخ الهجرية +- تحسين الأداء في النماذج الكبيرة -## 🔧 Configuration +## ⚡ الأداء -**No configuration required!** The module works out of the box with intelligent defaults: +- **سرعة التحميل**: محسنة بنسبة 40% +- **استهلاك الذاكرة**: مخفض بنسبة 25% +- **الاستجابة**: أسرع بـ 60% +- **التوافق**: أفضل مع جميع المتصفحات -- **Automatic Detection**: Detects user language and applies appropriate formatting -- **RTL Support**: Automatically enables for Arabic users -- **Calendar Variant**: Uses the most common Islamic calendar calculation -- **Date Format**: Follows user's locale preferences +## 🛠️ التخصيص -### Optional Customization +يمكن تخصيص المظهر والسلوك عبر: -If you want to customize the behavior, you can modify these settings in your Odoo configuration: - -```python -# In your custom module or through Odoo settings -HIJRI_CALENDAR_VARIANT = 'islamic-civil' # or 'islamic-tbla', 'islamic-umalqura' -HIJRI_LOCALE = 'ar' # or 'fa', 'ur' -HIJRI_NUMBER_FORMAT = 'arabic' # 'arabic' for Arabic numerals, 'western' for 0-9 -``` - -## 🔄 How It Works - -### Gregorian to Hijri Conversion -```javascript -// Automatic conversion when Gregorian date is entered -gregorianDate = '2024-03-15' -hijriDate = '٦ رَمَضَان، ١٤٤٥' -``` - -### Hijri to Gregorian Conversion -```javascript -// Automatic conversion when Hijri date is selected -hijriDate = 'Ramadan 6, 1445' -gregorianDate = '2024-03-15' -``` - -### Real-time Synchronization -- Changes in either calendar instantly update the other -- Maintains data integrity with proper validation -- Handles edge cases and invalid dates gracefully - -## 🎨 Styling and Appearance - -### Matching Odoo's Design System -- **Colors**: Uses Odoo's standard color palette -- **Typography**: Follows Odoo's font hierarchy and sizing -- **Spacing**: Consistent margins and padding -- **Animations**: Subtle transitions matching Odoo's style - -### Custom CSS Classes +### CSS Variables: ```css -.o_hijri_datepicker /* Hijri datepicker container */ -.o_hijri /* Hijri input field */ -.calendars-popup /* Popup calendar container */ -.calendars-selected /* Selected date styling */ -.calendars-today /* Today's date styling */ -``` - -## 🌐 Internationalization - -### Supported Languages -- **Arabic (ar)**: Full RTL support with Arabic numerals -- **English (en)**: LTR support with Western numerals -- **Persian/Farsi (fa)**: RTL support with Persian numerals -- **Urdu (ur)**: RTL support - -### Localization Features -- **Month Names**: Translated month names in each language -- **Number Systems**: Appropriate numeral system for each locale -- **Text Direction**: Automatic RTL/LTR handling -- **Date Formats**: Locale-appropriate date formatting - -## 🛡️ Browser Compatibility - -| Browser | Version | Status | -|---------|---------|--------| -| Chrome | 70+ | ✅ Full Support | -| Firefox | 65+ | ✅ Full Support | -| Safari | 12+ | ✅ Full Support | -| Edge | 79+ | ✅ Full Support | -| Internet Explorer | 11 | ⚠️ Limited Support | - -## 📱 Mobile Support - -- **Responsive Design**: Adapts to all screen sizes -- **Touch Optimization**: Touch-friendly date selection -- **Native Integration**: Uses native date picker when appropriate -- **Performance**: Optimized for mobile performance - -## 🔍 Technical Details - -### Dependencies -- **Odoo**: 14.0+ -- **jQuery**: Included with Odoo -- **Bootstrap**: 4.x (Odoo standard) -- **jQuery Calendars**: 2.2.0 (bundled) - -### File Structure -``` -web_hijri_datepicker/ -├── __init__.py -├── __manifest__.py -├── static/ -│ ├── src/ -│ │ ├── js/ -│ │ │ └── web_hijri_date.js -│ │ ├── scss/ -│ │ │ ├── hijri_modern.css -│ │ │ └── web_hijri_date.scss -│ │ └── xml/ -│ │ └── web_hijri_date.xml -│ └── lib/ -│ └── jquery.calendars.package-2.2.0/ -└── views/ - └── web_hijri_template.xml -``` - -### Performance Metrics -- **Bundle Size**: ~150KB (minified) -- **Load Time**: <200ms initialization -- **Memory Footprint**: <2MB additional -- **Conversion Speed**: <1ms per conversion - -## 🐛 Troubleshooting - -### Common Issues and Solutions - -#### Issue: Hijri datepicker not showing -**Solution**: Ensure jQuery Calendars library is loaded properly -```javascript -// Check if library is loaded -if (typeof $.calendars === 'undefined') { - console.error('jQuery Calendars library not loaded'); +:root { + --hijri-primary-color: #6c5ce7; + --hijri-secondary-color: #74b9ff; + --hijri-border-radius: 8px; + --hijri-shadow: 0 8px 25px rgba(0, 0, 0, 0.15); } ``` -#### Issue: Wrong Z-index (popup behind other elements) -**Solution**: The module automatically uses z-index 1051. If still having issues: -```css -.calendars-popup { - z-index: 9999 !important; -} +### JavaScript Options: +```javascript +// إعدادات مخصصة +$.calendarsPicker.setDefaults({ + showSpeed: 'fast', + showAnim: 'slideDown', + yearRange: 'c-50:c+50' +}); ``` -#### Issue: RTL text not displaying correctly -**Solution**: Ensure proper Arabic font is available: -```css -.calendars.arabic-numbers { - font-family: 'Segoe UI', Tahoma, Arial, sans-serif; -} -``` +## 📞 الدعم -## 🤝 Contributing +للدعم الفني أو الاستفسارات: +- 📧 Email: support@example.com +- 📱 WhatsApp: +966xxxxxxxxx +- 🌐 Website: www.example.com -We welcome contributions! Please follow these steps: +## 📄 الرخصة -1. **Fork** the repository -2. **Create** a feature branch (`git checkout -b feature/amazing-feature`) -3. **Commit** your changes (`git commit -m 'Add amazing feature'`) -4. **Push** to the branch (`git push origin feature/amazing-feature`) -5. **Open** a Pull Request +هذا الموديول مرخص تحت رخصة MIT. -### Development Setup -```bash -# Clone the repository -git clone https://github.com/your-repo/web_hijri_datepicker.git +## 🤝 المساهمة -# Install development dependencies -pip install -r requirements-dev.txt +نرحب بمساهماتكم لتطوير الموديول: +1. Fork المشروع +2. أنشئ branch جديد للميزة +3. Commit التغييرات +4. Push إلى Branch +5. أنشئ Pull Request -# Run tests -python -m pytest tests/ -``` +## 📈 خارطة الطريق -## 📄 License - -This project is licensed under the LGPL-3.0 License - see the [LICENSE](LICENSE) file for details. - -## 🆘 Support - -- **Documentation**: [docs.expertsolutions.sa](https://docs.expertsolutions.sa) -- **Email**: support@expertsolutions.sa -- **Issue Tracker**: [GitHub Issues](https://github.com/your-repo/issues) -- **Live Demo**: [demo.expertsolutions.sa](https://demo.expertsolutions.sa/hijri-datepicker) - -## 🏆 Credits - -- **Lead Developer**: Expert Solutions Team -- **Islamic Calendar Library**: Keith Wood (jQuery Calendars) -- **Arabic Localization**: Community Contributors -- **Testing**: Odoo Community - -## 📈 Changelog - -### v2.3.0 (2024-08-28) -- **Perfect Odoo 14 Integration**: Complete visual and functional compatibility -- **Performance Improvements**: 40% faster loading, 25% less memory -- **Enhanced Styling**: Pixel-perfect match with Odoo's standard datepicker -- **Better Error Handling**: Robust validation and conversion -- **Accessibility**: Screen reader and keyboard navigation support - -### v2.2.0 (Previous) -- Updated jQuery Calendars library to v2.2.0 -- Modern responsive UI design -- Enhanced Arabic/RTL language support -- Improved performance and memory optimization - -### v2.1.0 -- Initial enhanced version -- Basic Hijri calendar integration -- Arabic month names and numerals +### 🔮 القادم في الإصدارات القادمة: +- دعم المزيد من التقاويم +- تكامل مع الموبايل app +- ميزات AI للتحويل الذكي +- تحسينات الأداء المستمرة --- -**Made with ❤️ by Expert Solutions for the Odoo Community** \ No newline at end of file +## 🏆 شكر خاص + +شكراً لـ Keith Wood على مكتبة jQuery Calendars الرائعة. + +**النسخة الحالية**: 2.2.0 +**تاريخ التحديث**: أغسطس 2025 +**الحالة**: ✅ مستقر ومجرب \ No newline at end of file diff --git a/odex25_base/web_hijri_datepicker/__manifest__.py b/odex25_base/web_hijri_datepicker/__manifest__.py index b47f374f5..3790546b7 100644 --- a/odex25_base/web_hijri_datepicker/__manifest__.py +++ b/odex25_base/web_hijri_datepicker/__manifest__.py @@ -1,90 +1,53 @@ # -*- coding: utf-8 -*- { - 'name': 'Enhanced Web Hijri Datepicker for Odoo 14', - 'version': '2.3.0', + 'name': 'Web Hijri Datepicker Enhanced', + 'version': '2.2.0', 'category': 'Web/Tools', - 'summary': 'Modern Hijri Calendar with Perfect Odoo 14 Integration', + 'summary': 'Modern Hijri Calendar Integration with Enhanced UI/UX', 'description': """ -Enhanced Web Hijri Datepicker v2.3.0 - Odoo 14 Standard Compatible -================================================================== +Enhanced Web Hijri Datepicker v2.2.0 +===================================== -🎯 **Perfect Integration with Odoo 14 Standard Datepicker** +🌟 **Major Update with Modern Design and Performance Improvements** -This enhanced version provides seamless Hijri calendar integration that perfectly matches Odoo's standard datepicker appearance and behavior while maintaining all Islamic calendar functionality. +**New Features:** +• Updated jQuery Calendars library to v2.2.0 +• Modern, responsive UI design matching Odoo's aesthetics +• Enhanced Arabic/RTL language support +• Improved performance and memory optimization +• Better error handling and validation +• Smooth animations and transitions +• Mobile-friendly responsive design -**🌟 Key Features:** +**Key Improvements:** +• 40% faster loading times +• 25% reduced memory usage +• 60% better responsiveness +• Enhanced integration with Odoo forms +• Improved accessibility features +• Better cross-browser compatibility -**Visual Integration:** -• **Exact Odoo 14 Styling**: Matches standard datepicker appearance pixel-perfect -• **Bootstrap 4 Compatible**: Uses same CSS framework as Odoo -• **Consistent Z-index**: Proper layering with Odoo's modal system (1051) -• **Responsive Design**: Works perfectly on all screen sizes -• **RTL Support**: Full Arabic language and right-to-left text support +**Features:** +• Automatic conversion between Gregorian and Hijri dates +• Real-time synchronization of both calendars +• Beautiful modern popup calendar interface +• Full Arabic language support with proper RTL +• Clear placeholders and intuitive user experience +• Seamless integration with all Odoo date fields -**Technical Excellence:** -• **Same Dimensions**: 22rem width matching Odoo standard (352px) -• **Unified Color Scheme**: Uses Odoo's exact color variables -• **Tempus Dominus Style**: Visual compatibility with Odoo's datepicker library -• **Enhanced Performance**: 40% faster loading, 25% reduced memory usage -• **Error Handling**: Robust validation and conversion mechanisms +**Technical Specs:** +• Compatible with Odoo 14.0+ +• Supports multiple Islamic calendar variants +• Responsive design for all screen sizes +• Modern CSS3 with smooth animations +• Enhanced JavaScript with error handling +• Optimized for production environments -**User Experience:** -• **Dual Calendar Display**: Gregorian and Hijri dates side by side -• **Automatic Synchronization**: Real-time conversion between calendars -• **Smart Positioning**: Intelligent popup placement avoiding viewport edges -• **Accessibility**: Screen reader support and keyboard navigation -• **Form Integration**: Seamless integration with Odoo forms and list views - -**Hijri Calendar Features:** -• **Accurate Conversions**: Precise Islamic calendar calculations -• **Multiple Variants**: Support for different Islamic calendar systems -• **Arabic Numerals**: Proper Arabic-Indic numeral display -• **Month Names**: Traditional Arabic month names with diacritics -• **Lunar Accuracy**: Astronomically accurate lunar month calculations - -**Developer Features:** -• **Clean Architecture**: Follows Odoo 14 widget patterns -• **Extensible Design**: Easy to customize and extend -• **Proper Events**: Standard Odoo field change events -• **Memory Management**: Proper cleanup and resource management -• **Cross-browser**: Works on all modern browsers - -**Integration Points:** -• **Form Views**: Enhanced date fields with Hijri display -• **List Views**: Inline editing with dual calendar support -• **Readonly Mode**: Elegant Hijri date display in readonly fields -• **Search Views**: Compatible with date range filters -• **Reports**: Hijri dates in QWeb reports and exports - -**Technical Specifications:** -• **Odoo Version**: 14.0+ (fully compatible) -• **Dependencies**: Only requires 'web' module -• **Size**: Optimized bundle size for fast loading -• **Languages**: Arabic, English with RTL support -• **Calendars**: Gregorian ↔ Islamic conversion engine -• **Standards**: Follows Odoo coding standards and best practices - -**Performance Metrics:** -• **Load Time**: Sub-200ms initialization -• **Memory Usage**: <2MB additional footprint -• **Conversion Speed**: <1ms per date conversion -• **Compatibility**: 100% backward compatible - -This module transforms every standard date field in Odoo into a dual-calendar system, allowing users to work naturally with both Gregorian and Islamic calendar dates while maintaining the familiar Odoo interface. - -**Perfect for:** -• Islamic organizations and businesses -• Multi-cultural companies in MENA region -• Educational institutions with Islamic calendar needs -• Government organizations requiring Hijri date compliance -• Any Odoo installation serving Arabic-speaking users - -**Installation & Usage:** -Simply install the module and all date fields will automatically gain Hijri calendar functionality. No configuration required - works out of the box! +This module automatically adds Hijri date picker functionality below every standard date field in Odoo, providing users with an intuitive way to work with Islamic calendar dates. """, - 'author': 'Expert Solutions', - 'website': 'https://www.expertsolutions.sa', + 'author': 'Your Company', + 'website': 'https://www.yourcompany.com', 'license': 'LGPL-3', 'depends': ['web'], 'data': [ @@ -92,11 +55,8 @@ Simply install the module and all date fields will automatically gain Hijri cale ], 'assets': { 'web.assets_backend': [ - # Enhanced CSS with Odoo 14 compatibility 'web_hijri_datepicker/static/src/scss/hijri_modern.css', 'web_hijri_datepicker/static/src/scss/web_hijri_date.scss', - - # jQuery Calendars Library v2.2.0 - Optimized loading order 'web_hijri_datepicker/static/lib/jquery.calendars.package-2.2.0/jquery.plugin.js', 'web_hijri_datepicker/static/lib/jquery.calendars.package-2.2.0/jquery.calendars.js', 'web_hijri_datepicker/static/lib/jquery.calendars.package-2.2.0/jquery.calendars.all.js', @@ -105,24 +65,12 @@ Simply install the module and all date fields will automatically gain Hijri cale 'web_hijri_datepicker/static/lib/jquery.calendars.package-2.2.0/jquery.calendars.islamic.js', 'web_hijri_datepicker/static/lib/jquery.calendars.package-2.2.0/jquery.calendars.islamic-ar.js', 'web_hijri_datepicker/static/lib/jquery.calendars.package-2.2.0/jquery.calendars.islamic-fa.js', - - # Time Entry Library v2.0.1 - Optional time support 'web_hijri_datepicker/static/lib/jquery.timeentry.package-2.0.1/jquery.timeentry.css', 'web_hijri_datepicker/static/lib/jquery.timeentry.package-2.0.1/jquery.plugin.js', 'web_hijri_datepicker/static/lib/jquery.timeentry.package-2.0.1/jquery.timeentry.js', 'web_hijri_datepicker/static/lib/jquery.timeentry.package-2.0.1/jquery.timeentry-ar.js', - - # Enhanced Hijri Integration - Load last for proper initialization 'web_hijri_datepicker/static/src/js/web_hijri_date.js', ], - 'web.assets_frontend': [ - # Minimal frontend support - 'web_hijri_datepicker/static/src/scss/hijri_modern.css', - 'web_hijri_datepicker/static/lib/jquery.calendars.package-2.2.0/jquery.plugin.js', - 'web_hijri_datepicker/static/lib/jquery.calendars.package-2.2.0/jquery.calendars.js', - 'web_hijri_datepicker/static/lib/jquery.calendars.package-2.2.0/jquery.calendars.islamic.js', - 'web_hijri_datepicker/static/lib/jquery.calendars.package-2.2.0/jquery.calendars.islamic-ar.js', - ], }, 'qweb': [ "static/src/xml/web_hijri_date.xml" @@ -130,8 +78,6 @@ Simply install the module and all date fields will automatically gain Hijri cale 'images': [ 'static/description/banner.png', 'static/description/icon.png', - 'static/description/screenshot_1.png', - 'static/description/screenshot_2.png', ], 'installable': True, 'auto_install': False, @@ -144,15 +90,11 @@ Simply install the module and all date fields will automatically gain Hijri cale 'python': [], 'bin': [], }, - 'maintainers': ['Expert Solutions Team'], - 'support': 'support@expertsolutions.sa', + 'maintainers': ['Your Name'], + 'support': 'support@yourcompany.com', 'price': 0, 'currency': 'USD', - 'live_test_url': 'https://demo.expertsolutions.sa/hijri-datepicker', + 'live_test_url': 'https://demo.yourcompany.com', 'demo': [], 'test': [], - 'sequence': 1, - 'web': True, - 'development_status': 'Production/Stable', - 'technical_name': 'web_hijri_datepicker', } \ No newline at end of file diff --git a/odex25_base/web_hijri_datepicker/static/src/js/web_hijri_date.js b/odex25_base/web_hijri_datepicker/static/src/js/web_hijri_date.js index a335ee4ec..f9c1f5b4f 100644 --- a/odex25_base/web_hijri_datepicker/static/src/js/web_hijri_date.js +++ b/odex25_base/web_hijri_datepicker/static/src/js/web_hijri_date.js @@ -1,25 +1,16 @@ -/** - * Enhanced Hijri Datepicker for Odoo 14 - * Seamless integration with Odoo's standard datepicker system - * Maintains all Hijri functionality while following Odoo's patterns - * Fixed placeholder handling for both Gregorian and Hijri fields - */ - -odoo.define('web_hijri_datepicker.enhanced_datepicker', function (require) { - 'use strict'; +odoo.define('web_hijri_datepicker.datepicker', function (require) { var core = require('web.core'); var datepicker = require('web.datepicker'); var field_utils = require('web.field_utils'); var time = require('web.time'); var FieldDate = require('web.basic_fields').FieldDate; - var session = require('web.session'); var _t = core._t; - // Enhanced Hijri month names with proper Arabic diacritics + // Enhanced Hijri month names with better Arabic support var hijriMonths = { "Muharram": "مُحَرَّم", - "Safar": "صَفَر", + "Safar": "صَفَر", "Rabi' al-awwal": "رَبِيْعُ الأَوّل", "Rabi' al-thani": "رَبِيْعُ الثَّانِي", "Jumada al-awwal": "جَمَادِي الأَوّل", @@ -30,152 +21,74 @@ odoo.define('web_hijri_datepicker.enhanced_datepicker', function (require) { "Shawwal": "شَوَّال", "Dhu al-Qi'dah": "ذُوالْقَعْدَة", "Dhu al-Hijjah": "ذُوالْحِجَّة" - }; + } - // Enhanced Arabic numeral conversion with better Unicode support - String.prototype.toArabicDigits = function () { - var arabicDigits = ['٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩']; + // Enhanced number conversion for better Arabic display + String.prototype.fromDigits = function () { + var arabicDigits = ['۰', '۱', '۲', '۳', '٤', '۵', '٦', '۷', '۸', '۹']; return this.replace(/[0-9]/g, function (digit) { return arabicDigits[+digit]; }); - }; + } - /** - * Enhanced DateWidget with improved Odoo integration and placeholder handling - */ datepicker.DateWidget.include({ - - /** - * Initialize the enhanced datepicker with proper placeholder handling - */ start: function () { var self = this; - var def = this._super.apply(this, arguments); - - // Get input elements this.$input = this.$('input.o_datepicker_input'); this.$input_hijri = this.$('input.o_hijri'); - if (!this.$input_hijri.length) { - return def; - } - - // Set proper placeholders based on locale - this._setupPlaceholders(); - - // Enhanced click handler with proper event delegation - this.$input_hijri.on('click.hijri_picker', function (e) { + // Enhanced click handler with better UX + this.$input_hijri.click(function (e) { e.preventDefault(); e.stopPropagation(); - self._showHijriPicker(); + self.$input_hijri.calendarsPicker('show'); }); - - // Focus handler for better UX - this.$input_hijri.on('focus.hijri_picker', function (e) { - if (!$(this).prop('readonly')) { - self._showHijriPicker(); - } - }); - - // Initialize Hijri picker with enhanced configuration - this._initializeHijriPicker(); - return def; - }, - - /** - * Setup proper placeholders for both Gregorian and Hijri inputs - */ - _setupPlaceholders: function () { - var locale = session.user_context.lang || 'en'; - var isArabic = locale.startsWith('ar'); - - // Gregorian input placeholder - var gregorianPlaceholder = isArabic ? - 'التاريخ الميلادي (مم/يي/سسسس)' : - 'Gregorian Date (mm/dd/yyyy)'; - - // Hijri input placeholder - var hijriPlaceholder = isArabic ? - 'التاريخ الهجري (الشهر اليوم، السنة)' : - 'Hijri Date (Month Day, Year)'; - - // Apply placeholders with fallback - if (this.$input && this.$input.length) { - this.$input.attr('placeholder', gregorianPlaceholder); - - // Also handle the case where placeholder might be overridden by Odoo - if (!this.$input.attr('placeholder') || this.$input.attr('placeholder').indexOf('mm/dd/yyyy') === -1) { - this.$input.attr('placeholder', gregorianPlaceholder); - } - } - - if (this.$input_hijri && this.$input_hijri.length) { - this.$input_hijri.attr('placeholder', hijriPlaceholder); - } - }, - - /** - * Initialize Hijri calendar picker with Odoo-compatible styling - */ - _initializeHijriPicker: function () { - var self = this; - - // Determine locale from Odoo session - var locale = session.user_context.lang || 'ar'; - var isRTL = ['ar', 'fa', 'he'].indexOf(locale.split('_')[0]) !== -1; - - // Enhanced picker configuration matching Odoo's datepicker behavior - var pickerConfig = { - calendar: $.calendars.instance('islamic', 'ar'), + // Modern configuration with enhanced features + this.$input_hijri.calendarsPicker({ + calendar: $.calendars.instance('islamic', this.options.locale || 'ar'), dateFormat: 'M d, yyyy', - showAnim: '', // Disable animation for consistency with Odoo + showAnim: 'slideDown', // Modern animation showSpeed: 'fast', showOnFocus: false, - closeOnDateSelect: true, - yearRange: 'c-100:c+50', + closeOnDateSelect: true, // Better UX - close after selection + yearRange: 'c-100:c+50', // Extended year range changeMonth: true, changeYear: true, showOtherMonths: true, selectOtherMonths: true, - localNumbers: true, - renderer: this._getOdooCompatibleRenderer(), - onSelect: this._onHijriDateSelect.bind(this), - onShow: this._onHijriPickerShow.bind(this), - onClose: this._onHijriPickerClose.bind(this), - beforeShow: this._beforeHijriPickerShow.bind(this) - }; - - // Apply RTL configuration if needed - if (isRTL) { - pickerConfig.isRTL = true; - } - - // Initialize the picker - try { - this.$input_hijri.calendarsPicker(pickerConfig); - } catch (error) { - console.warn('Hijri datepicker initialization error:', error); - } + localNumbers: true, // Enable Arabic numerals + renderer: this._getModernRenderer(), + onSelect: this._convertDateToHijri.bind(this), + onShow: function() { + // Add modern CSS class for styling + $('.calendars-popup').addClass('hijri-modern-popup'); + } + }); + + this.__libInput++; + this.$el.datetimepicker(this.options); + this.__libInput--; + this._setReadonly(false); }, /** - * Get renderer configuration that matches Odoo's datepicker appearance + * Get modern renderer configuration for better styling */ - _getOdooCompatibleRenderer: function () { + _getModernRenderer: function() { return $.extend({}, $.calendarsPicker.defaultRenderer, { - picker: '