Merge branch 'dev_odex25_takaful' of https://github.com/expsa/odex25-standard-modules into esterdad_bugs

 Conflicts:
	odex25_takaful/odex_takaful/models/donation_details_lines.py
This commit is contained in:
Ali Ammar 2025-12-22 10:26:10 +03:00
commit 20f6ad7f8b
11 changed files with 163 additions and 67 deletions

View File

@ -7614,3 +7614,23 @@ msgstr "العمر"
msgid "Diseases Attachment"
msgstr "الأمراض"
#. module: odex_takaful
#: model:ir.model.fields.selection,name:odex_takaful.selection__family_member__benefit_group__orphan
msgid "Orphans"
msgstr "الأيتام"
#. module: odex_takaful
#: model:ir.model.fields.selection,name:odex_takaful.selection__family_member__benefit_group__widow
msgid "Widows"
msgstr "أم الايتام"
#. module: odex_takaful
#: model:ir.model.fields.selection,name:odex_takaful.selection__product_template__target_donation__not_target
msgid "Not Target"
msgstr "تبرعات"
#. module: odex_takaful
#: model:ir.model.fields.selection,name:odex_takaful.selection__product_template__target_donation__target
msgid "Target"
msgstr "حملات"

View File

@ -21,7 +21,6 @@ class DonationsDetailsLines(models.Model):
journal_id = self.env.company.sponsorship_direct_debit_journal_id.id
return journal_id if journal_id else False
name = fields.Text(string="Note")
display_type = fields.Selection([
('line_section', "Section"),
@ -99,6 +98,7 @@ class DonationsDetailsLines(models.Model):
debit_payment_attachment_file_name = fields.Char('Debit Payment File Name', required=False)
journal_id = fields.Many2one('account.journal', string="Journal",domain="[('type','=','bank')]",default=_default_journal_id)
benefit_status = fields.Selection(related='benefit_id.member_status')
non_benefit_reason = fields.Text(related='benefit_id.non_benefit_reason')
diseases_attachment_ids = fields.Many2many('ir.attachment', compute='_compute_get_diseases')
ages = fields.Integer(compute='_compute_get_age_range' , store=True)
age = fields.Integer(related='benefit_id.age')
@ -156,9 +156,7 @@ class DonationsDetailsLines(models.Model):
is_manager = (
user.has_group('odex_takaful.sponsorship_system_manager_group') or
user.has_group('odex_takaful.branch_manager_group'))
print('is_manager >>>>> ' , is_manager)
print('rec.create_uid >>>>> ' , rec.create_uid)
rec.can_edit_benefit = (rec.create_uid == user and is_manager)
rec.can_edit_benefit = (rec.create_uid == user and not is_manager)
@api.depends('sponsorship_duration', 'payment_month_count', 'direct_debit')
def _compute_age_category(self):
for rec in self:
@ -350,7 +348,11 @@ class DonationsDetailsLines(models.Model):
def onset_benefit_id(self):
for rec in self:
if rec.state == 'waiting' and (rec.benefit_id or rec.benefit_ids):
rec.state = 'active'
if rec.sponsorship_duration == 'permanent':
rec.state = 'paid'
else:
rec.state = 'active'
sponsor_id = rec.sponsorship_mechanism_id.sponsor_id.id if rec.sponsorship_mechanism_id else rec.sponsorship_id.sponsor_id.id
(rec.benefit_id | rec.benefit_ids).write(
{'sponsor_related_id': sponsor_id, 'kafala_status': 'have_kafala', "sponsorship_end_date": rec.end_date if rec.end_date else False})
@ -365,11 +367,6 @@ class DonationsDetailsLines(models.Model):
for rec in self:
rec.total_months_amount = rec.donation_amount * rec.payment_month_count
@api.onchange('sponsorship_duration')
def _onchange_sponsorship_duration(self):
for rec in self:
if rec.sponsorship_duration == "permanent":
rec.direct_debit = False
@api.onchange('product_template_id')
def _onchange_product_template_id(self):
@ -610,9 +607,14 @@ class DonationsDetailsLines(models.Model):
_("Payment Month Count should be greather than zero!")
)
@api.onchange('sponsorship_duration', 'direct_debit', 'record_type')
@api.onchange('sponsorship_duration', 'direct_debit', 'record_type', 'start_date')
def _onchange_sponsorship_duration(self):
for rec in self:
if rec.sponsorship_duration == "permanent":
rec.direct_debit = False
rec.payment_month_count = 1
rec.benefit_id = False
rec.benefit_ids = [(5, 0, 0)]
if rec.record_type == "sponsorship" and rec.sponsorship_duration:
product_templ_id = self.env["product.template"].sudo().search([("sponsorship_duration", "=", rec.sponsorship_duration)], limit=1)
if product_templ_id:
@ -620,6 +622,12 @@ class DonationsDetailsLines(models.Model):
if rec.sponsorship_duration == 'temporary' and not rec.direct_debit:
rec.start_date = fields.Date.context_today(rec)
@api.onchange('payment_month_count')
def _onchange_payment_month_count(self):
for rec in self:
rec.benefit_id = False
rec.benefit_ids = [(5, 0, 0)]
@api.model
@ -636,14 +644,14 @@ class DonationsDetailsLines(models.Model):
return res
@api.onchange('donation_types', 'donation_type')
@api.onchange('donation_types', 'donation_type', 'record_type')
def _onchange_sponsorship_type(self):
for rec in self:
if rec.sponsorship_mechanism_id:
if rec.sponsorship_mechanism_id.record_type == 'sponsorship':
rec.donation_type = 'sponsorship'
if rec.donation_types:
elif rec.donation_types:
if rec.donation_types == 'donation':
rec.donation_type = 'donation'
elif rec.donation_types == 'waqf':
@ -681,6 +689,21 @@ class DonationsDetailsLines(models.Model):
else:
rec.total_donation_amount = rec.total_months_amount * (rec.benefits_count or 1)
@api.depends('record_type', 'benefit_id')
def _compute_family_id(self):
for rec in self:
if rec.family_id:
rec.benefit_family_code = rec.family_id.code
continue
family = False
if rec.record_type == 'sponsorship':
if rec.benefit_id and rec.benefit_id.benefit_id:
family = rec.benefit_id.benefit_id
rec.family_id = family or False
rec.benefit_family_code = family.code if family else False
@api.depends('family_id','record_type')
def _compute_family_domain_ids(self):
for rec in self:
@ -840,7 +863,7 @@ class DonationsDetailsLines(models.Model):
'domain': {
'product_template_id': domain}
}
@api.onchange('donation_type')
def onchange_donation_type(self):

View File

@ -45,6 +45,41 @@ class FamilyMember(models.Model):
string='Kafala Status', compute='_compute_kafala_status', store=True, readonly=True)
education_levels = fields.Many2one("education.level", string='Education Levels', compute='_compute_education_levels', store=True)
number_of_family_member = fields.Integer(compute='_compute_number_of_family_member' , store=True, string='Number Of Family Member')
benefit_group = fields.Selection(
[
('orphan', 'Orphans'),
('widow', 'Widows'),
('other', 'Other'),
],
compute='_compute_benefit_group',
store=True
)
def name_get(self):
result = []
show_age = self.env.context.get('show_age_in_kafalat')
for rec in self:
name = rec.name or ''
age = rec.age
type = ''
if show_age and age:
if rec.benefit_group:
type = rec.benefit_group
name = f"{name} - {age} - {type}"
result.append((rec.id, name))
return result
@api.depends('relationn_type')
def _compute_benefit_group(self):
for rec in self:
if rec.relationn_type in ('son', 'daughter'):
rec.benefit_group = 'orphan'
elif rec.relationn_type in ('mother', 'replacement_mother'):
rec.benefit_group = 'widow'
else:
rec.benefit_group = 'other'
@api.depends('benefit_id','relationn','member_status')
def _compute_number_of_family_member(self):

View File

@ -12,6 +12,16 @@ class ProductTemplate(models.Model):
string='Sponsorship Duration Type')
_quantity = fields.Float(default=0, store=True)
payment_method_id = fields.Many2one('takaful.payment.method', string="Payment Method")
target_donation = fields.Selection([('target', 'Target'), ('not_target', 'Not Target')],
string='Duration Targeted', compute='_compute_target_donation', store=True)
@api.depends('target_amount')
def _compute_target_donation(self):
for rec in self:
if rec.target_amount > 0 :
rec.target_donation = 'target'
else:
rec.target_donation = 'not_target'
def _compute_fixed_value(self):
for rec in self:

View File

@ -11,6 +11,7 @@
<field name="benefit_id"/>
<field name="product_template_id"/>
<field name="branch_custom_id"/>
<field name="family_id"/>
<field name="education_level"/>
<separator/>
<!-- State Filters -->
@ -78,7 +79,7 @@
<field name="sponsor_phone" widget="phone"/>
<field name="donation_type" optional="hide"/>
<field name="sponsorship_duration" optional="hide"/>
<field name="sponsorship_duration" />
<field name="donation_mechanism" optional="hide"/>
<field name="product_template_id" />
<field name="benefit_status" widget="badge"
@ -94,7 +95,8 @@
<field name="total_donation_amount" widget="monetary" options="{'currency_field': 'currency_id'}"/>
<field name="currency_id" invisible="1"/>
<field name="branch_custom_id" optional="hide" />
<field name="benefit_family_code" optional="hide" />
<field name="family_id" optional="hide" />
<!-- <field name="benefit_family_code" optional="hide" />-->
<field name="benefit_id" optional="hide" />
<!-- <field name="sponsorship_creation_date" />-->
<field name="create_date" optional="hide"/>
@ -166,6 +168,10 @@
<field name="state" widget="statusbar"
statusbar_visible="draft,confirmed,waiting,active,replace,closed" />
</header>
<div class="alert alert-danger" role="alert" style="margin-bottom:0px;text-align:center;"
attrs="{'invisible':[('benefit_status', '!=', 'non_benefit')]}">
<field name="non_benefit_reason" attrs="{'readonly': True}"/>
</div>
<sheet>
<div class="oe_button_box" name="button_box">
<button name="action_view_extension_history"
@ -238,6 +244,7 @@
<page string="Sponsorship Details" attrs="{'invisible': [('donation_mechanism', '!=', 'with_conditions')]}">
<group>
<group>
<field name="benefit_status" invisible="1" />
<field name="display_type" invisible="1" />
<field name="sequence" invisible="1" />
<field name="sponsorships_computed" invisible="1" />
@ -396,7 +403,8 @@
<field name="total_donation_amount" widget="monetary" options="{'currency_field': 'currency_id'}"/>
<field name="currency_id" invisible="1"/>
<field name="branch_custom_id" optional="hide" />
<field name="benefit_family_code" optional="hide" />
<field name="family_id" optional="hide" />
<!-- <field name="benefit_family_code" optional="hide" />-->
<field name="benefit_id" optional="hide" />
<!-- <field name="sponsorship_creation_date" />-->
<field name="create_date" optional="hide"/>
@ -449,7 +457,8 @@
<field name="total_donation_amount" widget="monetary" options="{'currency_field': 'currency_id'}"/>
<field name="currency_id" invisible="1"/>
<field name="branch_custom_id" optional="hide" />
<field name="benefit_family_code" optional="hide" />
<field name="family_id" optional="hide" />
<!-- <field name="benefit_family_code" optional="hide" />-->
<field name="benefit_id" optional="hide" />
<!-- <field name="sponsorship_creation_date" />-->
<field name="create_date" optional="hide"/>

View File

@ -99,10 +99,11 @@
domain="[('education_status', '=', 'under_study_age')]"/>
<separator/>
<group>
<filter string="Education Level"
name="group_education_level"
context="{'group_by': 'education_levels'}"/>
</group>
<filter string="Orphans / Widows" name="group_benefit_type" context="{'group_by': 'benefit_group'}"/>
<filter string="Education Level"
name="group_education_level"
context="{'group_by': 'education_levels'}"/>
</group>
</field>
</field>
</record>

View File

@ -125,5 +125,28 @@
</field>
</field>
</record>
<record id="product_template_search_odex_takaful" model="ir.ui.view">
<field name="name">product.template.search.odex.takaful</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_search_view"/>
<field name="arch" type="xml">
<xpath expr="//search/filter[1]" position="before">
<filter string="Target"
name="target_donation_true"
domain="[('target_donation','=','target')]"/>
<filter string="Not Target"
name="target_donation_false"
domain="[('target_donation','=','not_target')]"/>
<separator/>
</xpath>
</field>
</record>
</odoo>

View File

@ -320,7 +320,8 @@
<!-- 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}"/>
options="{'no_create': True, 'no_create_edit':True, 'no_open': True}"
context="{'group_by': 'target_donation'}"/>
<field name="name" widget="section_and_note_text" optional="show"/>
<field name="direct_debit"/>
<field name="journal_id"
@ -550,7 +551,8 @@
<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}"/>
options="{'no_create': True, 'no_create_edit':True, 'no_open': True}"
context="{'group_by': 'target_donation'}"/>
<field name="payment_month_count_visibility" invisible="1"/>
<field name="direct_debit"
attrs="{'invisible': [('sponsorship_duration','=','permanent')]}"/>
@ -635,8 +637,9 @@
<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}" context="{'group_by': 'benefit_group'}">
<tree editable="bottom">
<field name="benefit_group" invisible="1"/>
<field name="name"/>
<field name="age"/>
<field name="member_status"/>

View File

@ -11,7 +11,7 @@
<field name="members_domain_ids" invisible="1"/>
<group>
<group string="Benefit Information">
<field name="benefit_id"/>
<field name="benefit_id" context="{'group_by': 'benefit_group', 'show_age_in_kafalat': True}" options="{'no_create': True, 'no_create_edit':True,'no_open': True}"/>
</group>
</group>

View File

@ -116,6 +116,7 @@ class ReplacementWiz(models.TransientModel):
def _compute_members_domain_ids(self):
for rec in self:
domain = []
if rec.record_type == 'sponsorship':
domain = [
'|',
@ -130,46 +131,17 @@ class ReplacementWiz(models.TransientModel):
('sponsor_related_id', '=', False),
('general_restriction', '=', False)
]])
# if rec.old_members_id.relationn.relation_type in ['mother','replacement_mother']:
# domain = expression.AND([domain, [
# ('relationn.relation_type', 'in', ['mother', 'replacement_mother'])
# ]])
# elif rec.old_members_id.relationn.relation_type in ['son','daughter']:
# domain = expression.AND([domain, [
# ('relationn.relation_type', 'in', ['son', 'daughter'])
# ]])
if 1 <= rec.old_members_id.age <= 6:
domain = expression.AND([domain, [
('age', '>=',1)
]])
domain = expression.AND([domain, [
('age', '<=', 6)
]])
elif 7 <= rec.old_members_id.age <= 10:
domain = expression.AND([domain, [
('age', '>=',7)
]])
domain = expression.AND([domain, [
('age', '<=', 10)
]])
elif 11 <= rec.old_members_id.age <= 15:
domain = expression.AND([domain, [
('age', '>=',11)
]])
domain = expression.AND([domain, [
('age', '<=', 15)
]])
elif 16 <= rec.old_members_id.age <= 18:
domain = expression.AND([domain, [
('age', '>=',16)
]])
domain = expression.AND([domain, [
('age', '<=', 18)
]])
elif rec.old_members_id.age > 18:
domain = expression.AND([domain, [
('age', '>',18)
]])
if rec.sponsorship_id.sponsorship_duration == 'temporary':
benefit_age_limit = None
if rec.sponsorship_id.direct_debit:
benefit_age_limit = 16
elif rec.sponsorship_id.payment_month_count < 6:
benefit_age_limit = 18
if benefit_age_limit:
domain = expression.AND([domain, [
('age', '>=', benefit_age_limit)
]])
members = self.env['family.member'].sudo().search(domain)

View File

@ -42,7 +42,7 @@
<field name="old_family_id" attrs="{'invisible': [('record_type', '=', 'sponsorship')], 'required': [('record_type', '=', 'donation')]}"/>
<field name="old_members_id" attrs="{'invisible': [('record_type', '=', 'donation')], 'required': [('record_type', '=', 'sponsorship')]}"/>
<field name="new_family_id" attrs="{'invisible': [('record_type', '=', 'sponsorship')], 'required': [('record_type', '=', 'donation')]}" options="{'no_create': True, 'no_create_edit':True, 'no_open': True}"/>
<field name="new_members_id" attrs="{'invisible': [('record_type', '=', 'donation')], 'required': [('record_type', '=', 'sponsorship')]}" options="{'no_create': True, 'no_create_edit':True,'no_open': True}"/>
<field name="new_members_id" attrs="{'invisible': [('record_type', '=', 'donation')], 'required': [('record_type', '=', 'sponsorship')]}" options="{'no_create': True, 'no_create_edit':True,'no_open': True}" context="{'group_by': 'benefit_group', 'show_age_in_kafalat': True}"/>
</group>
<group string="Replacement Reason">