fix: comprehensive UI/UX improvements for takaful module
- Fixed partner.sponsor.form: added default value for preferred_communication (first record) - Fixed partner.sponsor.form: corrected button_box class name for Odoo compatibility - Fixed button selection visibility: buttons now maintain selection state after save - Improved help messages: made them more intelligent and context-aware - Updated page title: changed from 'Donation Details' to 'Conditional Donation/Sponsorship Details' - Fixed sponsor_id clearing: now clears when switching donor/sponsor types - Fixed Sponsor Name translation: changed to Arabic 'اسم الكافل/المتبرع' - Added _onSave method to JavaScript to ensure UI re-initialization after save - Added onchange methods to clear sponsor_id when type changes - Removed mode condition from _update to ensure UI works in all modes All changes are Odoo 14 compatible, tested, and follow best practices.
This commit is contained in:
parent
b5c6bdedb3
commit
54def08c0b
|
|
@ -52,7 +52,12 @@ class ResPartner(models.Model):
|
|||
('verified', 'Verified')
|
||||
], string='State',default='draft', tracking=True)
|
||||
|
||||
preferred_communication = fields.Many2one('preferred.communication', string="Preferred Communication")
|
||||
def _get_default_preferred_communication(self):
|
||||
"""Get first preferred communication method as default"""
|
||||
first_comm = self.env['preferred.communication'].search([], limit=1, order='id asc')
|
||||
return first_comm if first_comm else False
|
||||
|
||||
preferred_communication = fields.Many2one('preferred.communication', string="Preferred Communication", default=_get_default_preferred_communication)
|
||||
serial_code = fields.Char(string="Serial Code", readonly=True, copy=False)
|
||||
|
||||
responsible_user_ids = fields.Many2many(
|
||||
|
|
|
|||
|
|
@ -761,6 +761,20 @@ class TakafulSponsorship(models.Model):
|
|||
rec.sponsor_or_donor_type = 'registered'
|
||||
elif rec.sponsor_donor_type == 'new_sponsor':
|
||||
rec.sponsor_or_donor_type = 'new_sponsor'
|
||||
# Clear sponsor_id when switching to new_sponsor
|
||||
if rec.sponsor_id:
|
||||
rec.sponsor_id = False
|
||||
else:
|
||||
# Clear sponsor_id when switching to unknown or other types
|
||||
if rec.sponsor_id:
|
||||
rec.sponsor_id = False
|
||||
|
||||
@api.onchange('sponsor_or_donor_type')
|
||||
def _onchange_sponsor_or_donor_type(self):
|
||||
for rec in self:
|
||||
# Clear sponsor_id when not 'registered'
|
||||
if rec.sponsor_or_donor_type != 'registered' and rec.sponsor_id:
|
||||
rec.sponsor_id = False
|
||||
|
||||
|
||||
def _get_default_record_type(self):
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@
|
|||
|
||||
_update: function () {
|
||||
var result = this._super.apply(this, arguments);
|
||||
if (this.mode === 'edit' && this.modelName === 'takaful.sponsorship') {
|
||||
if (this.modelName === 'takaful.sponsorship') {
|
||||
var self = this;
|
||||
setTimeout(function() {
|
||||
self._setupSimpleUI();
|
||||
|
|
@ -192,6 +192,17 @@
|
|||
return result;
|
||||
},
|
||||
|
||||
_onSave: function () {
|
||||
var result = this._super.apply(this, arguments);
|
||||
if (this.modelName === 'takaful.sponsorship') {
|
||||
var self = this;
|
||||
setTimeout(function() {
|
||||
self._setupSimpleUI();
|
||||
}, 100);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
_setupSimpleUI: function () {
|
||||
var self = this;
|
||||
|
||||
|
|
@ -203,11 +214,22 @@
|
|||
this.$('.record_option').on('click', function () {
|
||||
var $option = $(this);
|
||||
var recordType = $option.data('value');
|
||||
var currentData = self.model.localData[self.handle].data;
|
||||
|
||||
// Clear sponsor_id when changing type if not registered
|
||||
var sponsorOrDonorType = currentData.sponsor_or_donor_type;
|
||||
var sponsorDonorType = currentData.sponsor_donor_type;
|
||||
var changes = {record_type: recordType};
|
||||
|
||||
// Clear sponsor_id if switching types and not 'registered'
|
||||
if (sponsorOrDonorType !== 'registered' && sponsorDonorType !== 'registered') {
|
||||
changes.sponsor_id = false;
|
||||
}
|
||||
|
||||
// Update field value using Odoo 14 method
|
||||
self.trigger_up('field_changed', {
|
||||
dataPointID: self.handle,
|
||||
changes: {record_type: recordType}
|
||||
changes: changes
|
||||
});
|
||||
|
||||
// Update visual selection
|
||||
|
|
|
|||
|
|
@ -130,12 +130,12 @@
|
|||
<!-- Help Messages Section -->
|
||||
<div class="alert alert-info text-center"
|
||||
attrs="{'invisible': [('record_type','!=','donation')]}">
|
||||
<i class="fa fa-heart text-success"/> اختر نوع التبرع ثم أدخل بيانات المتبرع
|
||||
<i class="fa fa-heart text-success"/> أدخل بيانات المتبرع ثم حدد تفاصيل التبرع
|
||||
</div>
|
||||
|
||||
<div class="alert alert-primary text-center"
|
||||
attrs="{'invisible': [('record_type','!=','sponsorship')]}">
|
||||
<i class="fa fa-users text-primary"/> أدخل بيانات الكافل ثم اختر المستفيد
|
||||
<i class="fa fa-users text-primary"/> أدخل بيانات الكافل ثم انتقل لإضافة تفاصيل الكفالة
|
||||
</div>
|
||||
|
||||
<group name="group_top">
|
||||
|
|
@ -153,7 +153,7 @@
|
|||
attrs="{'invisible': [('record_type','!=','sponsorship')], 'required': [('record_type','=','sponsorship')], 'readonly': [('state','!=','draft')]}"/>
|
||||
</div>
|
||||
|
||||
<label string="Sponsor Name" for="sponsor_id"/>
|
||||
<label string="اسم الكافل/المتبرع" for="sponsor_id"/>
|
||||
<div class="o_row">
|
||||
<field name="sponsor_id" nolabel="1"
|
||||
context="{'form_view_ref': 'odex_takaful.view_takaful_sponsor_form'}"
|
||||
|
|
@ -259,7 +259,7 @@
|
|||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Donation Details">
|
||||
<page name="sponsorship_details" string="Conditional Donation/Sponsorship Details">
|
||||
<field name="donations_details_lines"
|
||||
context="{'default_active_id': active_id,'default_donation_mechanism': 'without_conditions','default_start_date': sponsorship_creation_date}"
|
||||
widget="section_and_note_one2many"
|
||||
|
|
|
|||
|
|
@ -45,8 +45,7 @@
|
|||
<field name="type" invisible="1"/>
|
||||
<field name="lang" invisible="1"/>
|
||||
|
||||
<div name="oe_button_box" class="oe_button_box">
|
||||
|
||||
<div name="button_box" class="oe_button_box">
|
||||
<button class="oe_stat_button" type="object" name="view_sponsorship_action" icon="fa-dollar">
|
||||
<field string="Kafalat" name="kafalat_count" widget="statinfo"/>
|
||||
</button>
|
||||
|
|
|
|||
Loading…
Reference in New Issue