[FIX] Solve issues

This commit is contained in:
odoo-syria-team 2025-11-16 12:38:02 +03:00
parent b5a42f2c64
commit 79facb44e4
2 changed files with 67 additions and 54 deletions

View File

@ -111,20 +111,26 @@ class DonationsDetailsLines(models.Model):
def _compute_get_age_range(self):
for rec in self:
x = []
records = self.env['donations.details.lines'].search(['|' , ('state', '=', 'replace') , ('state', '=', 'waiting')])
for record in records:
branch_id = rec.branch_custom_id.id
records = self.env['donations.details.lines'].search(['|' , ('state', '=', 'replace') , ('state', '=', 'waiting') ])
filtered_records = records.filtered(lambda r: r.sponsorship_mechanism_id.branch_custom_id.id == branch_id)
if record.sponsorship_duration == 'permanent':
for record in filtered_records:
if record.sponsorship_duration == 'permanent' :
x.append(1)
elif record.sponsorship_duration != 'permanent' and record.payment_month_count > 6:
x.append(1)
elif record.sponsorship_duration != 'permanent' and record.payment_month_count < 6 and record.direct_debit:
elif record.sponsorship_duration != 'permanent' and record.payment_month_count < 6 and record.direct_debit :
x.append(16)
elif record.sponsorship_duration != 'permanent' and record.payment_month_count < 6:
x.append(18)
else:
elif record.sponsorship_duration != 'permanent' and record.payment_month_count >= 6 :
x.append(1)
lowest_value = min(x) if x else None
elif record.sponsorship_duration != 'permanent' and record.payment_month_count < 6 :
x.append(18)
if len(x) > 0 :
lowest_value = min(x) if x else None
else:
lowest_value = 100
rec.ages = lowest_value
@api.depends('extension_history_ids')
@ -495,6 +501,7 @@ class DonationsDetailsLines(models.Model):
parent_record = self.env['takaful.sponsorship'].browse(parent_id)
res['sponsorship_creation_date'] = parent_record.sponsorship_creation_date
res['branch_custom_id'] = parent_record.branch_custom_id
# res['donation_mechanism'] = parent_record.donation_mechanism
self._onchange_sponsorship_type()

View File

@ -79,18 +79,18 @@
<field name="refund_move_count" string="Refund Invoices"
widget="statinfo"/>
</button>
<!-- <button name="action_replacement_processes" type="object"-->
<!-- string="Replacement Processes" class="oe_stat_button" icon="fa-users">-->
<!-- </button>-->
<!-- <button name="action_replacement_processes" type="object"-->
<!-- string="Replacement Processes" class="oe_stat_button" icon="fa-users">-->
<!-- </button>-->
</div>
<!-- Code badge hidden for now -->
<!-- <div style="position: absolute; top: 70px; right: 15px; z-index: 100;" attrs="{'invisible': [('code', '=', False)]}">
<span class="badge badge-info" style="font-size: 14px; padding: 6px 12px;">
<i class="fa fa-barcode"/> <field name="code" nolabel="1" readonly="1"/>
</span>
</div> -->
<!-- Record Type Selection - Simple & Clean Design -->
<div class="o_record_type_simple">
<div class="record_type_options">
@ -103,7 +103,7 @@
<span>كفالة</span>
</div>
</div>
<!-- Hidden field for actual value -->
<field name="record_type" readonly="0" nolabel="1" invisible="1"
groups="!odex_takaful.branch_manager_group,!odex_takaful.sponsorship_system_manager_group,odex_takaful.donation_officer_group,odex_takaful.sponsorship_officer_group"/>
@ -111,9 +111,9 @@
groups="odex_takaful.branch_manager_group,odex_takaful.sponsorship_system_manager_group"
attrs="{'readonly': [('state','!=','draft')]}"/>
</div>
<!-- Donation Type Selection - Only for Donations -->
<div class="o_donation_mechanism_simple"
<div class="o_donation_mechanism_simple"
attrs="{'invisible': [('record_type','!=','donation')]}">
<div class="mechanism_options">
<div class="mechanism_option without_conditions" data-value="without_conditions">
@ -125,30 +125,32 @@
<span>مشروط</span>
</div>
</div>
<!-- Hidden field for actual value -->
<field name="donation_mechanism" invisible="1" nolabel="1"
attrs="{'required': [('record_type','=','donation')], 'readonly': [('state','!=','draft')]}"/>
</div>
<!-- Help Messages Section -->
<div class="alert alert-info text-center"
<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"
<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">
<group name="group_left" string="Donor Information">
<field name="manager_id" invisible="1"/>
<field name="is_donations_coordinator" invisible="1"/>
<field name="is_sponsorship_coordinator" invisible="1"/>
<field name="registered_type" invisible="1" attrs="{'readonly': [('state','!=','draft')]}"/>
<label string="Sponsor / Donor Type" for="sponsor_or_donor_type"/>
<div class="o_row">
<field name="sponsor_or_donor_type"
@ -156,7 +158,7 @@
<field name="sponsor_donor_type"
attrs="{'invisible': [('record_type','!=','sponsorship')], 'required': [('record_type','=','sponsorship')], 'readonly': [('state','!=','draft')]}"/>
</div>
<label string="اسم الكافل/المتبرع" for="sponsor_id"
attrs="{
'invisible': ['|',
@ -178,11 +180,11 @@
],
'readonly': [('state','!=','draft')]
}"
force_save="1"
force_save="1"
options="{'no_create': True, 'no_create_edit': True}"/>
<button name="create_new_sponsor" type="object"
string="إنشاء مشترك"
string="إنشاء مشترك"
class="btn-primary oe_highlight"
icon="fa-plus"
attrs="{
@ -193,7 +195,7 @@
]
}"/>
</div>
<field name="sponsor_phone" string="رقم الجوال" widget="phone"
attrs="{
'invisible': ['|',
@ -203,7 +205,7 @@
'readonly': [('state','!=','draft')]
}"
placeholder="05xxxxxxxx"/>
<field name="preferred_communication" string="طريقة التواصل المفضلة"
attrs="{
'invisible': ['|',
@ -212,27 +214,27 @@
],
'readonly': [True]
}"
force_save="1"
force_save="1"
options="{'no_create': True, 'no_create_edit': True}"/>
</group>
<group name="group_right" string="Basic Information">
<field name="is_widow_orphan" invisible="1"/>
<field name="cancel_refund" invisible="1"/>
<field name="has_delay" invisible="1"/>
<field name="members_domain_ids" invisible="1"/>
<field name="donate_for_another_person" widget="boolean_toggle"
attrs="{'readonly': [('state', '!=', 'draft')]}"/>
<field name="sponsorship_creation_date" readonly="1"/>
<field name="create_uid" string="Sponsorship Creator" readonly="1"/>
<field name="branch_custom_id" groups="!odex_takaful.sponsorship_system_manager_group"
readonly="0"/>
<field name="branch_custom_id"
groups="odex_takaful.sponsorship_system_manager_group"
attrs="{'readonly': [('state','!=','draft')]}"/>
<field name="marketer_id" attrs="{'readonly': [('state','!=','draft')]}"
context="{'default_domain_force_all': True}"/>
</group>
@ -278,8 +280,8 @@
<tree editable="bottom">
<control>
<create name="add_line_control" string="Add a line"/>
<!-- <create name="add_section_control" string="Add a section"-->
<!-- context="{'default_display_type': 'line_section'}"/>-->
<!-- <create name="add_section_control" string="Add a section"-->
<!-- context="{'default_display_type': 'line_section'}"/>-->
<!-- <button name="action_delegate_to_catalog" string="Catalog" type="object" class="px-4 btn-link" context="{'sponsorship_id': parent.id}"/>-->
</control>
<field name="sponsorship_duration" invisible="1"/>
@ -304,11 +306,12 @@
invisible="1" force_save="1"/>
<!-- attrs="{'column_invisible': [('parent.record_type', '!=', 'donation')], 'required': [('parent.record_type', '=', 'donation'), ('display_type', '=', False)]}"-->
<field name="product_template_id"
attrs="{'required': [('display_type', '=', False)]}" options="{'no_create': True, 'no_create_edit':True, 'no_open': True}"/>
attrs="{'required': [('display_type', '=', False)]}"
options="{'no_create': True, 'no_create_edit':True, 'no_open': True}"/>
<field name="name" widget="section_and_note_text" optional="show"/>
<field name="direct_debit"/>
<field name="journal_id"
attrs="{'invisible': [('direct_debit', '=', False)], 'required': [('direct_debit', '=', True)]}"/>
attrs="{'invisible': [('direct_debit', '=', False)], 'required': [('direct_debit', '=', True)]}"/>
<!-- <field name="cheque_number"
attrs="{'required': [('payment_method', '=', 'check')], 'invisible': [('payment_method', '!=', 'check')]}"/>
@ -394,7 +397,8 @@
<!-- 'column_invisible': [('parent.record_type', '!=', 'donation')],-->
<!-- 'required': [('parent.record_type', '=', 'donation'), ('display_type', '=', False)]}"/>-->
<field name="product_template_id"
attrs="{'required': [('display_type', '=', False)]}" options="{'no_create': True, 'no_create_edit':True, 'no_open': True}"/>
attrs="{'required': [('display_type', '=', False)]}"
options="{'no_create': True, 'no_create_edit':True, 'no_open': True}"/>
<field name="name"
widget="section_and_note_text" optional="show"/>
<field name="direct_debit"/>
@ -462,13 +466,13 @@
icon="fa-plus-circle"
attrs="{'invisible': [('show_extend_button', '=', False)]}"/>
<button string="Add Benefit"
<button string="Add Benefit"
name="add_benefit_wizard"
type="object"
class="btn-primary"
icon="fa-plus-circle"
attrs="{'invisible': [('show_add_benefit_button', '=', False)]}"
groups="odex_takaful.group_kufula_user" />
groups="odex_takaful.group_kufula_user"/>
<button name="action_view_replacement_wizard"
string="Orphan Replacement"
type="object"
@ -487,12 +491,12 @@
<form string="Donation Details">
<header>
<button string="Add Benefit"
name="add_benefit_wizard"
type="object"
class="btn-primary"
icon="fa-plus-circle"
attrs="{'invisible': [('show_add_benefit_button', '=', False)]}"
groups="odex_takaful.group_kufula_user" />
name="add_benefit_wizard"
type="object"
class="btn-primary"
icon="fa-plus-circle"
attrs="{'invisible': [('show_add_benefit_button', '=', False)]}"
groups="odex_takaful.group_kufula_user"/>
<button name="action_view_replacement_wizard"
string="Orphan Replacement"
type="object"
@ -529,7 +533,8 @@
<field name="record_type" invisible="1"/>
<field name="sponsorship_duration"
attrs="{'invisible': [('record_type','!=','sponsorship')], 'required': [('record_type','=','sponsorship')]}"/>
<field name="product_template_id" options="{'no_create': True, 'no_create_edit':True, 'no_open': True}"/>
<field name="product_template_id"
options="{'no_create': True, 'no_create_edit':True, 'no_open': True}"/>
<field name="payment_month_count_visibility" invisible="1"/>
<field name="direct_debit"
attrs="{'invisible': [('sponsorship_duration','=','permanent')]}"/>
@ -538,7 +543,8 @@
<field name="donation_types"
invisible="1"/>
<field name="sponsor_id" invisible="1"/>
<field name="direct_debit_partner_bank_id" context="{'form_view_ref': 'odex_takaful.res_partner_bank_view_form_quick_create', 'default_partner_id': sponsor_id}"
<field name="direct_debit_partner_bank_id"
context="{'form_view_ref': 'odex_takaful.res_partner_bank_view_form_quick_create', 'default_partner_id': sponsor_id}"
attrs="{'invisible': ['|', ('payment_month_count_visibility','!=', True),('direct_debit', '=', False)], 'required': [('direct_debit', '=', True)]}"/>
<field name="journal_id"
attrs="{'invisible': ['|', ('payment_month_count_visibility','!=', True),('direct_debit', '=', False)], 'required': [('direct_debit', '=', True)]}"/>
@ -613,7 +619,7 @@
<page string="Orphans and Widows List"
attrs="{'invisible': ['|',('sponsorship_type', '!=', 'group'), ('hide_beneficiary_group', '=', True)]}">
<!-- attrs="{'invisible': ['|', '|', '|', ('hide_beneficiary_group','=', True), ('parent.record_type','!=','sponsorship'), ('sponsorship_type', '!=', 'group'), ('benefit_type', '!=', 'both')]}">-->
<field name="benefit_ids" nolabel="1" options="{'no_create': True}">
<field name="benefit_ids" nolabel="1" options="{'no_create': True}">
<tree editable="bottom">
<field name="name"/>
<field name="age"/>