feat: Display code as prominent badge only after generation

**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
This commit is contained in:
Mohamed Eltayar 2025-11-12 04:46:15 +03:00
parent 9bca8f8300
commit 3986c53e26
1 changed files with 10 additions and 3 deletions

View File

@ -83,9 +83,16 @@
<!-- string="Replacement Processes" class="oe_stat_button" icon="fa-users">-->
<!-- </button>-->
</div>
<h1>
<field name="code" nolabel="1"/>
</h1>
<!-- Code Badge - Only shown after code is generated -->
<div class="oe_title" attrs="{'invisible': [('code', '=', False)]}">
<h2 style="margin-top: 10px; margin-bottom: 15px;">
<span class="badge badge-primary" style="font-size: 18px; padding: 10px 20px; font-weight: 600; letter-spacing: 1px;">
<i class="fa fa-barcode" style="margin-right: 8px;"/>
<field name="code" nolabel="1" readonly="1"/>
</span>
</h2>
</div>
<!-- Record Type Selection - Simple & Clean Design -->
<div class="o_record_type_simple">