**المشكلة:**
Field show_add_benefit_button used in attrs.invisible but missing from view
ValidationError during module upgrade
**الحل:**
إضافة <field name="show_add_benefit_button" invisible="1"/> في tree view
**السبب:**
الـ commit السابق (2bc13b62) لم يتم دمجه في PR #5384
Synced with latest dev_odex25_ensan (2e3d0238) on Wed Nov 12 13:45:50 +03 2025
**المشكلة:**
- تم إضافة widget='section_and_note_one2many'
- تم إضافة editable='bottom'
- تم إضافة <control> section
- هذا منع فتح wizard form وجعل التحرير inline
**الحل:**
- إزالة widget='section_and_note_one2many'
- إزالة editable='bottom'
- إزالة <control> section
- الرجوع للكود الأصلي قبل 5 مساءً يوم 11-11
**النتيجة:**
- زر 'إضافة بند' الآن يفتح wizard form كما كان سابقاً ✅
Synced with dev_odex25_ensan on Wed Nov 12 13:35:10 +03 2025
- Changed && to && in isEditable logic (line 213)
- Fixes XMLSyntaxError: xmlParseEntityRef: no name
Synced with dev_odex25_ensan on Wed Nov 12 05:40:15 +03 2025
- Removed form mode check - buttons now editable in draft state
- Moved code badge to top-right corner (absolute positioning)
- Smaller badge size (14px, compact padding)
- No longer blocks form width
Synced with dev_odex25_ensan on Wed Nov 12 05:10:51 +03 2025
**Problem:**
- Code field (<h1>) was always visible, even when empty
- Wasted vertical space at top of form during record creation
- Not professional appearance with empty heading
**Solution:**
- Code field now HIDDEN until generated (when code is empty/False)
- After "تأكيد البيانات" (Confirm Data), code appears as beautiful badge
- Uses attrs="{'invisible': [('code', '=', False)]}"
**Badge Design:**
- Blue badge (badge-primary) with barcode icon
- Large, bold font (18px, font-weight: 600)
- Generous padding (10px 20px)
- Letter spacing for readability
- No label - just icon + code
- Example: [🔖 KF00001]
**Before:**
```xml
<h1>
<field name="code" nolabel="1"/>
</h1>
```
Result: Empty <h1> space visible during creation ❌
**After:**
```xml
<div class="oe_title" attrs="{'invisible': [('code', '=', False)]}">
<h2 style="margin-top: 10px; margin-bottom: 15px;">
<span class="badge badge-primary" style="...">
<i class="fa fa-barcode" style="margin-right: 8px;"/>
<field name="code" nolabel="1" readonly="1"/>
</span>
</h2>
</div>
```
Result:
- Clean form during creation ✅
- Beautiful badge after confirmation ✅
**User Experience:**
| Stage | Before | After |
|-------|--------|-------|
| **New Record** | Empty <h1> visible ❌ | Code section hidden ✅ |
| **After Confirm** | Code in plain <h1> | Blue badge with icon 🔖✅ |
| **Visual Impact** | Basic | Professional & Prominent ✅ |
**Technical Details:**
- Replaced <h1> with styled badge in <h2>
- Added FontAwesome barcode icon (fa-barcode)
- Used Odoo standard badge-primary class
- Added custom styling for prominence
- Proper margins for spacing (10px top, 15px bottom)
**Code Generation Timing:**
Code is generated in `action_confirm_data()` method:
```python
if not self.code:
self.code = self.env['ir.sequence'].sudo().next_by_code('sponsorship.sequence')
```
**Benefits:**
1. ✅ Clean form during creation (no empty space)
2. ✅ Prominent, professional badge after confirmation
3. ✅ Easy to spot and read the code number
4. ✅ No label clutter - icon communicates purpose
5. ✅ Better UX - information appears when relevant
File modified:
- odex25_ensan/odex_takaful/views/takaful_sponorship_view.xml
Synced with latest dev_odex25_ensan on Wed Nov 12 04:46:15 +03 2025
Changed icon reference from icon5.png to icon.png to match
the updated icon file and menu web_icon reference.
This ensures consistency across:
- __manifest__.py (module definition)
- takaful_menus_actions.xml (menu web_icon)
- Actual icon file (icon.png)
File modified:
- odex25_ensan/odex_takaful/__manifest__.py
Part of the complete icon update cleanup.
**Problem with previous PR #5369:**
The merged PR had WRONG logic that allowed buttons to become editable
when user clicks 'Edit' on confirmed/posted records.
**Previous WRONG Logic:**
```javascript
var isReadonly = currentData.state !== 'draft' || self.mode === 'readonly';
// ❌ If mode='edit' AND state!='draft' → buttons become clickable!
```
**New CORRECT Logic:**
```javascript
var isDraftState = currentData.state === 'draft';
// ✅ Buttons ONLY work if state='draft', regardless of form mode
```
**Key Change:**
- ❌ OLD: Check both state AND mode → allows editing in non-draft states
- ✅ NEW: Check ONLY state → readonly in ALL non-draft states
**User Requirement:**
الأزرار تكون للقراءة فقط في جميع الحالات ما عدا draft فقط،
حتى لو عملت تحرير للسجل.
**Behavior Now:**
- draft state → Buttons work ✅
- confirmed/posted + readonly mode → Buttons disabled ✅
- confirmed/posted + edit mode → Buttons REMAIN disabled ✅ (FIXED!)
This is the correct implementation that meets the exact requirement.
Synced with latest dev_odex25_ensan on Wed Nov 12 03:58:56 +03 2025