Merge pull request #5351 from expsa/feature/enhance-record-type-ui-and-fixes-20251111-2051

 Genius Record Type UI Enhancement & Multiple UX Fixes
This commit is contained in:
Mohamed Eltayar 2025-11-11 20:54:42 +03:00 committed by GitHub
commit 7b2036e11c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 137 additions and 33 deletions

View File

@ -7248,7 +7248,7 @@ msgstr "اسم الكافل/المتبرع"
#. module: odex_takaful
#: model:ir.model.fields,field_description:odex_takaful.field_donations_details_lines__direct_debit_partner_bank_id
msgid "Direct Debit Partner Bank"
msgstr "البنك المتبرع"
msgstr "بنك المتبرع"
#. module: odex_takaful
#: code:addons/odex_takaful/models/takaful_sponorship_model.py:0

View File

@ -682,8 +682,8 @@ class TakafulSponsorship(models.Model):
last_invoice_date = fields.Date(string='Last Invoice')
voucher_ids = fields.One2many('account.move','sponsorship_id',string='Vouchers', copy=False)
record_type = fields.Selection([
('sponsorship', 'Sponsorship'),
('donation', 'Donation'),
('sponsorship', 'Sponsorship'),
], string="Record Type", required=True, default=lambda self: self._get_default_record_type(), copy=False)
is_donations_coordinator = fields.Boolean(string="Is Donations Coordinator", compute='_compute_is_coordinator')
is_sponsorship_coordinator = fields.Boolean(string="Is Sponsorship Coordinator", compute='_compute_is_coordinator')

View File

@ -13,23 +13,99 @@
</template>
<!-- تحسينات بسيطة للتكافل -->
<template id="takaful_simple_enhancements" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<style>
/* تحسينات بسيطة فقط */
.o_form_label {
font-weight: 500;
}
<template id="takaful_simple_enhancements" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<style>
/* تحسينات بسيطة فقط */
.o_form_label {
font-weight: 500;
}
.o_field_widget.o_field_monetary input {
font-weight: 600;
}
.o_field_widget.o_field_phone input {
direction: ltr;
}
/* Record Type Enhanced Design */
.o_record_type_section {
background: #f8f9fa;
padding: 20px;
border-radius: 8px;
margin: 15px 0;
}
.record_type_card {
background: white;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
transition: all 0.3s ease;
min-height: 120px;
display: flex;
flex-direction: column;
justify-content: center;
}
.record_type_card:hover {
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(0,0,0,0.15);
border-color: #007bff !important;
}
.record_type_card.selected {
border-color: #28a745 !important;
border-width: 2px !important;
background: #f8fff9;
}
.o_record_type_section h3 {
color: #495057;
font-weight: 600;
}
.o_record_type_section .o_field_widget {
display: none; /* Hide the original radio buttons */
}
</style>
.o_field_widget.o_field_monetary input {
font-weight: 600;
}
.o_field_widget.o_field_phone input {
direction: ltr;
}
</style>
</xpath>
</template>
<script type="text/javascript">
odoo.define('takaful.record_type_enhancement', function (require) {
'use strict';
var FormController = require('web.FormController');
FormController.include({
start: function () {
var self = this;
return this._super.apply(this, arguments).then(function () {
if (self.modelName === 'takaful.sponsorship') {
self._setupRecordTypeCards();
}
});
},
_setupRecordTypeCards: function () {
var self = this;
this.$('.record_type_card').on('click', function () {
var $card = $(this);
var recordType = $card.find('h4').text().trim() === 'تبرع' ? 'donation' : 'sponsorship';
// Update the field value
var recordTypeField = self.renderer.allFieldWidgets.record_type;
if (recordTypeField && recordTypeField.length > 0) {
recordTypeField[0]._setValue(recordType);
}
// Update visual selection
self.$('.record_type_card').removeClass('selected');
$card.addClass('selected');
});
}
});
});
</script>
</xpath>
</template>
</odoo>

View File

@ -86,6 +86,41 @@
<h1>
<field name="code" nolabel="1"/>
</h1>
<!-- Record Type Selection - Enhanced Design -->
<div class="o_record_type_section mb-3">
<div class="row">
<div class="col-12">
<h3 class="text-center mb-3">اختر نوع السجل</h3>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="record_type_card text-center p-3 border rounded" style="cursor: pointer; transition: all 0.3s;">
<i class="fa fa-heart fa-3x text-success mb-2"></i>
<h4 class="text-success">تبرع</h4>
<p class="text-muted small">تبرعات عامة ومشروطة</p>
</div>
</div>
<div class="col-md-6">
<div class="record_type_card text-center p-3 border rounded" style="cursor: pointer; transition: all 0.3s;">
<i class="fa fa-users fa-3x text-primary mb-2"></i>
<h4 class="text-primary">كفالة</h4>
<p class="text-muted small">كفالة الأيتام والأرامل</p>
</div>
</div>
</div>
<!-- Hidden field for actual value -->
<field name="record_type" readonly="0" widget="radio"
options="{'horizontal': true}"
groups="!odex_takaful.branch_manager_group,!odex_takaful.sponsorship_system_manager_group,odex_takaful.donation_officer_group,odex_takaful.sponsorship_officer_group"/>
<field name="record_type" widget="radio"
options="{'horizontal': true}"
groups="odex_takaful.branch_manager_group,odex_takaful.sponsorship_system_manager_group"
attrs="{'readonly': [('state','!=','draft')]}"/>
</div>
<group name="group_top">
<group name="group_left" string="Donor Information">
<field name="manager_id" invisible="1"/>
@ -93,14 +128,6 @@
<field name="is_sponsorship_coordinator" invisible="1"/>
<field name="registered_type" invisible="1" attrs="{'readonly': [('state','!=','draft')]}"/>
<field name="record_type" readonly="0" widget="radio"
options="{'horizontal': true}"
groups="!odex_takaful.branch_manager_group,!odex_takaful.sponsorship_system_manager_group,odex_takaful.donation_officer_group,odex_takaful.sponsorship_officer_group"/>
<field name="record_type" widget="radio"
options="{'horizontal': true}"
groups="odex_takaful.branch_manager_group,odex_takaful.sponsorship_system_manager_group"
attrs="{'readonly': [('state','!=','draft')]}"/>
<field name="donation_mechanism"
attrs="{'invisible': [('record_type','!=','donation')], 'required': [('record_type','=','donation')], 'readonly': [('state','!=','draft')]}"/>
@ -121,7 +148,7 @@
}"/>
</div>
<field name="sponsor_id"
<field name="sponsor_id" string="Sponsor Name"
context="{'form_view_ref': 'odex_takaful.view_takaful_sponsor_form'}"
attrs="{'invisible': [('sponsor_id','=',False), ('sponsor_or_donor_type','!=','registered')],
'required':[('sponsor_or_donor_type','=','registered')],
@ -131,6 +158,9 @@
<field name="preferred_communication"
attrs="{'invisible': [('sponsor_id','=',False), ('sponsor_or_donor_type','!=','registered')]}"
force_save="1" options="{'no_create': True, 'no_create_edit': True}"/>
<field name="sponsor_phone" widget="phone"
attrs="{'invisible': [('sponsor_or_donor_type','=', False)], 'readonly': [('sponsor_or_donor_type', '!=', 'unknown')]}"/>
</group>
<group name="group_right" string="Basic Information">
@ -139,9 +169,6 @@
<field name="has_delay" invisible="1"/>
<field name="members_domain_ids" invisible="1"/>
<field name="sponsor_phone" widget="phone"
attrs="{'invisible': [('sponsor_or_donor_type','=', False)], 'readonly': [('sponsor_or_donor_type', '!=', 'unknown')]}"/>
<field name="donate_for_another_person" widget="boolean_toggle"/>
<field name="sponsorship_creation_date" readonly="1"/>
<field name="create_uid" string="Sponsorship Creator" readonly="1"/>
@ -213,7 +240,7 @@
<field name="family_domain_ids" invisible="1"/>
<field name="fixed_value" invisible="1"/>
<field name="sequence" widget="handle"/>
<field name="sequence_no" readonly="1"/>
<field name="sequence_no" readonly="1" optional="hide"/>
<field name="sponsorship_scheduling_line_ids" invisible="1"/>
<field name="show_extend_button" invisible="1"/>
<field name="donation_type"
@ -291,6 +318,7 @@
<field name="donations_details_lines_mechanism_ids"
context="{'default_active_id': id, 'default_donation_mechanism': 'with_conditions','default_start_date': sponsorship_creation_date, 'default_sponsor_id': sponsor_id, }"
widget="section_and_note_one2many"
attrs="{'invisible': [('donation_mechanism', '=', 'without_conditions')], 'readonly': [('state','!=','draft')]}">
<tree>
<field name="sponsorships_computed" invisible="1"/>
@ -302,7 +330,7 @@
<field name="state" invisible="1"/>
<field name="is_paid" invisible="1"/>
<field name="direct_debit" invisible="1"/>
<field name="sequence_no" readonly="1"/>
<field name="sequence_no" readonly="1" optional="hide"/>
<field name="donation_type"
invisible="1"/>
<!-- attrs="{'column_invisible': [('parent.record_type', '=', 'donation')],'required': ['|',('parent.record_type', '=', 'donation'),('display_type', '=', False)]}"/>-->