Merge pull request #4915 from expsa/abdulrahman_dev_odex25_ensan

notes
This commit is contained in:
abdurrahman-saber 2025-10-15 03:55:41 +03:00 committed by GitHub
commit 2c603d381c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 135 additions and 193 deletions

View File

@ -8,6 +8,7 @@
<field name="arch" type="xml">
<field name="donation_type" position="after">
<field name="donation_category" />
<field name="sponsorship_duration" attrs="{'invisible': [('donation_category','!=','sponsorship')], 'required': [('donation_category','=','sponsorship')]}" />
</field>
</field>
</record>

View File

@ -288,6 +288,15 @@ class FamilyMemberProfile(models.Model):
def _expand_states(self, states, domain, order):
return [key for key, val in type(self).state.selection]
@api.model
def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None):
if not args:
args = []
domain = ['|', ('name', operator, name), ('member_phone', operator, name)]
return self._search(domain, limit=limit, access_rights_uid=name_get_uid)
@api.onchange('age')
def _check_son_daughter_age(self):
for rec in self:

View File

@ -1466,7 +1466,7 @@ msgstr "إنشاء البنود"
#. module: odex_takaful
#: model_terms:ir.ui.view,arch_db:odex_takaful.takaful_sponsorship_form
msgid "Create New Sponsor"
msgstr "إنشاء كافل جديد"
msgstr "إنشاء مشترك جديد"
#. module: odex_takaful
#: model:ir.actions.server,name:odex_takaful.scheduler_monthly_create_sponsorship_invoice_action_ir_actions_server
@ -3629,7 +3629,7 @@ msgstr ""
#: model:ir.model.fields.selection,name:odex_takaful.selection__takaful_sponsorship__sponsor_donor_type__new_sponsor
#: model:ir.model.fields.selection,name:odex_takaful.selection__takaful_sponsorship__sponsor_or_donor_type__new_sponsor
msgid "New Sponsor"
msgstr "كافل جديد"
msgstr "مشترك جديد"
#. module: odex_takaful
#: model:ir.model.fields,field_description:odex_takaful.field_takaful_sponsor__payment_next_action_date
@ -3773,11 +3773,6 @@ msgstr "البريد الإلكتروني العادي"
msgid "Not Exist"
msgstr "غير موجود"
#. module: odex_takaful
#: model:ir.model.fields.selection,name:odex_takaful.selection__takaful_sponsorship__sponsor_or_donor_type__not_registered
msgid "Not Registered"
msgstr "غير مسجل"
#. module: odex_takaful
#: model:ir.model.fields,field_description:odex_takaful.field_donate_for_another_person__note
#: model:ir.model.fields,field_description:odex_takaful.field_donations_details_lines__name
@ -6252,7 +6247,7 @@ msgstr "الوحدات"
#. module: odex_takaful
#: model:ir.model.fields.selection,name:odex_takaful.selection__takaful_sponsorship__sponsor_or_donor_type__unknown
msgid "Unknown"
msgstr "غير معروف"
msgstr "فاعل خير"
#. module: odex_takaful
#: model:ir.model.fields.selection,name:odex_takaful.selection__sponsorship_scheduling_line__status__unpaid

View File

@ -35,7 +35,7 @@ class DonationsDetailsLines(models.Model):
family_id = fields.Many2one('grant.benefit',string='Family',ondelete='set null',related="benefit_id.benefit_id")
benefit_ids = fields.Many2many('family.member',string='Beneficiaries Names', tracking=True)
sponsorship_duration = fields.Selection([('temporary', 'Temporary'),('permanent', 'Permanent')],string='Sponsorship Type')
start_date = fields.Date(string="Sponsorship Start Date", copy=False)
start_date = fields.Date(string="Sponsorship Start Date", copy=False, default=fields.Date.today())
end_date = fields.Date(string="Sponsorship End Date",compute='_compute_end_date', store=True)
payment_option = fields.Selection([('month', 'Monthly'), ('once', 'For Once')], string='Payment Option')
payment_month_count = fields.Integer(string='Payment Month Count', default=1)
@ -57,14 +57,21 @@ class DonationsDetailsLines(models.Model):
sponsorship_scheduling_line_ids = fields.One2many('sponsorship.scheduling.line', 'donation_detail_linked_id')
is_paid = fields.Boolean(string="Is Paid", default=False)
parent_state = fields.Char(compute='_compute_parent_state')
hide_beneficiary_group = fields.Boolean(compute='_compute_hide_beneficiary_group')
@api.depends('sponsorship_duration', 'payment_method_id', 'record_type', 'start_date')
def _compute_hide_beneficiary_group(self):
for rec in self:
if rec.sponsorship_duration == 'temporary' and rec.payment_method == 'direct_debit' and rec.record_type == 'sponsorship' and rec.start_date != fields.Date.context_today(rec):
rec.hide_beneficiary_group = True
else:
rec.hide_beneficiary_group = False
@api.depends('sponsorship_id','sponsorship_mechanism_id')
def _compute_parent_state(self):
for rec in self:
rec.parent_state = rec.sponsorship_id.state if rec.sponsorship_id else rec.sponsorship_mechanism_id.state
@api.depends('sponsorship_id','sponsorship_mechanism_id', 'sponsorship_id.record_type', 'sponsorship_mechanism_id.record_type')
def _compute_record_type(self):
for rec in self:
@ -97,15 +104,10 @@ class DonationsDetailsLines(models.Model):
lines = self.search([('end_date', '!=', False)])
lines.check_end_date()
@api.depends('payment_month_count', 'product_template_id')
@api.depends('payment_month_count', 'product_template_id', 'sponsorship_duration')
def _compute_donation_amount(self):
for rec in self.with_context(recursive_onchanges=False):
if rec.payment_method == 'direct_debit':
rec.donation_amount = rec.product_template_id.list_price * rec.payment_month_count
elif not rec.donation_amount:
rec.donation_amount = rec.product_template_id.list_price
else:
rec.donation_amount = rec.donation_amount
rec.donation_amount = rec.product_template_id.list_price * rec.payment_month_count
def check_end_date(self):
for record in self:
@ -271,13 +273,18 @@ class DonationsDetailsLines(models.Model):
_("Payment Month Count should be greather than zero!")
)
@api.onchange('sponsorship_duration')
def _onchange_sponsorship_duration(self):
for rec in self:
if rec.sponsorship_duration == 'temporary' and rec.payment_method != 'direct_debit':
rec.start_date = fields.Date.context_today(rec)
@api.model
def default_get(self, fields):
res = super(DonationsDetailsLines, self).default_get(fields)
parent_id = self.env.context.get('default_active_id')
parent_record = self.env['takaful.sponsorship'].browse(parent_id)
res['start_date'] = parent_record.sponsorship_creation_date
res['sponsorship_creation_date'] = parent_record.sponsorship_creation_date
# res['donation_mechanism'] = parent_record.donation_mechanism
@ -439,7 +446,7 @@ class DonationsDetailsLines(models.Model):
domain = {'benefit_id': [('id', 'in', rec.members_domain_ids.ids)]}
return {'domain': domain}
@api.onchange('product_template_id','donation_types','donation_type')
@api.onchange('product_template_id','donation_types','donation_type','sponsorship_duration')
def onchange_product_template_id(self):
for rec in self:
# Process both donation details and mechanism details
@ -461,6 +468,7 @@ class DonationsDetailsLines(models.Model):
elif record_type == 'sponsorship':
domain.append(('donation_category', '=', 'sponsorship'))
domain.append(('sponsorship_duration', '=', rec.sponsorship_duration))
return {
'domain': {

View File

@ -5,6 +5,7 @@ class ProductTemplate(models.Model):
donation_category = fields.Selection([('donation', 'Donation'), ('sponsorship', 'Sponsorship'), ('endowment', 'Endowment')], string='Donation Category', required=True, default='donation')
fixed_value = fields.Boolean(string='Is Fixed Value?', compute='_compute_fixed_value')
sponsorship_duration = fields.Selection([('temporary', 'Temporary'),('permanent', 'Permanent')], string='Sponsorship Duration Type')
def _compute_fixed_value(self):
for rec in self:

View File

@ -69,7 +69,7 @@ class TakafulSponsorship(models.Model):
sponsor_or_donor_type = fields.Selection(string='Sponsor / Donor Type',selection=[('registered', 'Registered'), ('new_sponsor', 'New Sponsor'),('not_registered', 'Not Registered'),('unknown', 'Unknown')], required=True)
sponsor_donor_type = fields.Selection(string='Sponsor / Donor Type',selection=[('registered', 'Registered'), ('new_sponsor', 'New Sponsor')])
sponsor_name = fields.Char(string="Sponsor Name")
sponsor_phone = fields.Char(string="Sponsor Phone")
sponsor_phone = fields.Char(string="Sponsor Phone", related='sponsor_id.mobile', store=True)
sponsor_title = fields.Many2one('res.partner.title',string='Sponsor Title')
donate_for_another_person = fields.Boolean(string='Donate For Another Person')
another_sponsors = fields.One2many('donate.for.another.person','sponsorship_id')

View File

@ -21,20 +21,20 @@ class TakafulSponsor(models.Model):
_inherits = {'res.partner': 'partner_id'}
@api.model
def name_search(self, name, args=None, operator='ilike', limit=100):
def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None):
if not args:
args = []
# Extend the domain filter with custom search conditions
domain = ['|', '|', ('name', operator, name),('id_number', operator, name),('mobile', operator, name)]
# Combine domain filter with any existing args (domain filter in Many2one)
partners = self.search(domain + args, limit=limit)
partners = self._search(domain, limit=limit, access_rights_uid=name_get_uid)
return partners.name_get()
return partners
partner_id = fields.Many2one('res.partner', string='Partner', required=True,ondelete='cascade', copy=False)
user_id = fields.Many2one('res.users', string="Related User")
sponsor_partner_id = fields.Many2one(related='user_id.partner_id', string="The partner Associated with the Sponsor")
sponsor_title = fields.Many2one('res.partner.title',string='Title')
account_number = fields.Char(string="Account Number")
bank_entity_name = fields.Char(string="Bank Entity Name")
@ -84,20 +84,6 @@ class TakafulSponsor(models.Model):
('email_uniq', 'unique (email)', 'The Email Already Exist!'),
]
@api.onchange('company_type', 'first_name', 'second_name', 'middle_name', 'family_name')
def get_partner_name(self):
if self.company_type == 'person':
self.name = ''
if all([self.second_name, self.first_name, self.middle_name, self.family_name]):
self.name = self.first_name + " " + self.second_name + " " + self.middle_name + " " + self.family_name
elif all([self.second_name, self.first_name, self.middle_name, self.family_name, self.sponsor_title]):
self.name = self.sponsor_title.name + " " + self.first_name + " " + self.second_name + " " + self.middle_name + " " + self.family_name
else:
self.second_name = ''
self.first_name = ''
self.middle_name = ''
self.family_name = ''
@api.onchange('id_number','email')
def onchange_id_number(self):
for rec in self:

View File

@ -221,23 +221,22 @@
</record>
<!-- Groups for Department-based Access Control -->
<record id="group_grant_benefit_department_access" model="res.groups">
<field name="name">Grant Benefit - Department Access</field>
<record id="group_beneficiary_department_access" model="res.groups">
<field name="name">Beneficiary - Department Access</field>
<field name="category_id" ref="module_category_kufula"/>
<field name="comment">Limits grant.benefit records to user's department</field>
<field name="comment">Limits beneficiary records to user's department</field>
</record>
<record id="group_family_member_department_access" model="res.groups">
<field name="name">Family Member - Department Access</field>
<record id="group_sponsor_department_access" model="res.groups">
<field name="name">Sponsor - Department Access</field>
<field name="category_id" ref="module_category_kufula"/>
<field name="comment">Limits family.member records to user's department</field>
<field name="comment">Limits sponsor records to user's department</field>
</record>
<!-- Record Rules for Department-based Access Control -->
<record id="grant_benefit_department_rule" model="ir.rule">
<field name="name">Grant Benefit - Department Based Access</field>
<field name="model_id" ref="odex_benefit.model_grant_benefit"/>
<field name="groups" eval="[(4, ref('group_grant_benefit_department_access'))]"/>
<field name="groups" eval="[(4, ref('group_beneficiary_department_access'))]"/>
<field name="domain_force">[('branch_custom_id.branch', 'child_of', user.employee_id.department_id.id)]</field>
<field name="perm_read" eval="1"/>
<field name="perm_write" eval="1"/>
@ -248,13 +247,24 @@
<record id="family_member_department_rule" model="ir.rule">
<field name="name">Family Member - Department Based Access</field>
<field name="model_id" ref="odex_benefit.model_family_member"/>
<field name="groups" eval="[(4, ref('group_family_member_department_access'))]"/>
<field name="groups" eval="[(4, ref('group_beneficiary_department_access'))]"/>
<field name="domain_force">[('benefit_id.branch_custom_id.branch', 'child_of', user.employee_id.department_id.id)]</field>
<field name="perm_read" eval="1"/>
<field name="perm_write" eval="1"/>
<field name="perm_create" eval="1"/>
<field name="perm_unlink" eval="1"/>
</record>
<record id="sponsor_department_rule" model="ir.rule">
<field name="name">Sponsor - Department Based Access</field>
<field name="model_id" ref="odex_takaful.model_takaful_sponsor"/>
<field name="groups" eval="[(4, ref('group_sponsor_department_access'))]"/>
<field name="domain_force">[('branch_custom_id.branch', 'child_of', user.employee_id.department_id.id)]</field>
<field name="perm_read" eval="1"/>
<field name="perm_write" eval="1"/>
<field name="perm_create" eval="1"/>
<field name="perm_unlink" eval="1"/>
</record>
</data>

View File

@ -66,7 +66,7 @@
<field name="journal_entry_count" string="Invoices" widget="statinfo" />
</button>
<button name="action_view_journal_entries_vendor" type="object"
class="oe_stat_button" icon="fa-book">
class="oe_stat_button" icon="fa-book" attrs="{'invisible': ['|', ('record_type','!=','donation'), ('donation_mechanism','!=','with_conditions')]}">
<field name="journal_entry_count_vendor" string="Vendor Invoices" widget="statinfo" />
</button>
<button name="action_open_related_move_records" type="object"
@ -87,7 +87,7 @@
<field name="code" nolabel="1" />
</h1>
<group name="group_top">
<group name="group_left">
<group name="group_left" string="Donor Information">
<field name="record_type" readonly="1"
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"
@ -95,11 +95,6 @@
attrs="{'readonly': [('state','!=','draft')]}" />
<field name="donation_mechanism"
attrs="{'invisible': [('record_type','!=','donation')], 'required': [('record_type','=','donation')], 'readonly': [('state','!=','draft')]}" />
<field name="branch_custom_id"
groups="!odex_takaful.sponsorship_system_manager_group" readonly="1" />
<field name="branch_custom_id"
groups="odex_takaful.sponsorship_system_manager_group"
attrs="{'readonly': [('state','!=','draft')]}" />
<field name="manager_id" invisible="1" />
<field name="allowed_sponsor_ids" invisible="1" />
<field name="is_donations_coordinator" invisible="1" />
@ -110,104 +105,27 @@
attrs="{'invisible': [('record_type','!=','sponsorship')], 'readonly': [('state','!=','draft')]}" />
<field name="registered_type"
attrs="{'invisible': [('sponsor_or_donor_type','!=','registered')], 'required': [('sponsor_or_donor_type','=','registered')],'readonly': [('state','!=','draft')]}" />
<field name="sponsor_name"
attrs="{'invisible': [('sponsor_or_donor_type','!=','not_registered')], 'required': [('sponsor_or_donor_type','=','not_registered')],'readonly': [('state','!=','draft')]}" />
<field name="sponsor_title"
attrs="{'invisible': [('sponsor_or_donor_type','!=','not_registered'),('sponsor_or_donor_type','!=','unknown')],'readonly': [('state','!=','draft')]}" />
<field name="sponsor_phone"
attrs="{'invisible': [('sponsor_or_donor_type','!=','not_registered'),('sponsor_or_donor_type','!=','unknown')],'required': [('sponsor_or_donor_type','in', ('not_registered','unknown'))],'readonly': [('state','!=','draft')]}" />
<field name="sponsor_id"
attrs="{'invisible': [('sponsor_id','=',False), ('sponsor_or_donor_type','!=','registered')],
'required':[('sponsor_or_donor_type','=','registered')],
'readonly':[('state','!=','draft')]}"
force_save="1" options="{'no_create': True, 'no_create_edit': True}" />
<!-- <field name="sponsorship_type"/>-->
<!-- <field name="benefit_type"/>-->
<!-- <field name="sponsorship_class"/>-->
<field name="sponsor_phone" attrs="{'invisible': [('sponsor_id','=', False)]}" />
<field name="is_widow_orphan" invisible="1" />
<field name="cancel_refund" invisible="1" />
<!-- <field name="replacement_id" attrs="{'invisible':
[('replacement_id', '=', False)]}"
groups="odex_takaful.group_orphan_replacement"/>-->
<!-- <field name="gender"/>-->
<!-- <field name="age_category_id"/>-->
<!-- <field name="education_status"/>-->
<!-- <field name="education_level"/>-->
<!-- <field name="payment_option"/>-->
<!-- <field name="payment_journal_id" required="1" />-->
<!-- <field name="payment_method"/>-->
<!-- <field name="total_sponsorship_amount"/>-->
<!-- <field name="total_waqf_and_donation_amount"/>-->
<field name="donate_for_another_person" widget="boolean_toggle" />
<field name="has_delay" invisible="1" />
<field name="members_domain_ids" invisible="1" />
</group>
<group name="group_right">
<group name="group_right" string="Basic Information">
<field name="sponsorship_creation_date" readonly="1" />
<field name="create_uid" string="Sponsorship Creator" readonly="1" />
<field name="marketer_id"/>
<!-- <field name="sponsor_note" />-->
<!-- <div attrs="{'invisible': [('sponsorship_type', '!=',
'person')]}">-->
<!-- <label for="benefit_id" string="The Orphan" attrs="{'invisible':
['|',('sponsorship_type', '!=', 'person'), ('benefit_type', '!=',
'orphan')]}" style="font-weight: bold;"/>-->
<!-- <label for="benefit_id" string="The Widow" attrs="{'invisible':
['|',('sponsorship_type', '!=', 'person'), ('benefit_type', '!=',
'widow')]}" style="font-weight: bold;"/>-->
<!-- </div>-->
<!-- <field style="width: 290px; margin-right: 10px;" name="benefit_id"
nolabel="1" attrs="{'invisible': ['|',('sponsorship_type', '!=',
'person'), ('benefit_type', '=', False)]}"/>-->
<!-- <div attrs="{'invisible': [('sponsorship_type', '!=',
'group')]}">-->
<!-- <label for="benefit_count" string="Number Of Sponsorship Orphans
and Widows" style="font-weight: bold;"/>-->
<!-- <label for="benefit_count" string="Number Of Sponsorship Widows"
attrs="{'invisible': ['|',('sponsorship_type', '!=', 'group'),
('benefit_type', '!=', 'widow')]}" style="font-weight: bold;"/>-->
<!-- </div>-->
<!-- <field style="width: 290px; margin-right: 10px;"
name="benefit_count" nolabel="1"/>-->
<!-- <label for="min_needs_percent" string="Needs Percentage From"
attrs="{'invisible': ['|',('sponsorship_type', '!=', 'group'),
('benefit_type', '=', False)]}"/>-->
<!-- <div class="oe_inline">-->
<!-- <field name="min_needs_percent" placeholder="Min Value" nolabel="1"
attrs="{'invisible': ['|',('sponsorship_type', '!=', 'group'),
('benefit_type', '=', False)]}"/>-->
<!-- <field name="max_needs_percent" placeholder="Max Value" nolabel="1"
attrs="{'invisible': ['|',('sponsorship_type', '!=', 'group'),
('benefit_type', '=', False)]}"/>-->
<!-- </div>-->
<!-- <field name="family_id"/>-->
<!-- <field name="city_id"/>-->
<!-- <field name="sponsorship_duration" />-->
<!-- <field name="start_date" />-->
<!-- <field name="end_date" />-->
<!-- <field name="supporter_status" attrs="{'invisible':
[('sponsorship_type', '!=', 'person')]}"/>-->
<field name="branch_custom_id" groups="!odex_takaful.sponsorship_system_manager_group" readonly="1" />
<field name="branch_custom_id"
groups="odex_takaful.sponsorship_system_manager_group"
attrs="{'readonly': [('state','!=','draft')]}" />
<field name="marketer_id" attrs="{'readonly': [('state','!=','draft')]}"/>
</group>
</group>
@ -223,15 +141,6 @@
<field name="show_payment_details" invisible="1" />
</group>
<!-- <group>-->
<!-- <label for="load_amount" />-->
<!-- <div>-->
<!-- <field name="load_amount" class="oe_inline" style="margin-right:50px;"
readonly="1" force_save="1"/>-->
<!-- <span class="oe_inline text-muted"> Riyal</span>-->
<!-- </div>-->
<!-- </group>-->
<group string="Gifter Information"
attrs="{'invisible': [('is_gift', '!=', 'yes')]}">
<field name="gifter_id" readonly="1" />
@ -291,7 +200,7 @@
<field name="sponsorship_type" attrs="{'column_invisible': [('parent.donation_mechanism','!=','with_conditions'),('parent.record_type','!=','sponsorship')]}" />
<field name="benefit_id" attrs="{'column_invisible': [('parent.donation_mechanism','!=','with_conditions'),('parent.record_type','!=','sponsorship')]}" />
<field name="payment_month_count" attrs="{'invisible': [('payment_method', '!=', 'direct_debit')]}"/>
<field name="start_date" string="From" attrs="{'invisible': [('payment_method', '!=', 'direct_debit')], 'required': [('payment_method', '=', 'direct_debit')]} " />
<field name="start_date" string="From" attrs="{'invisible': [('payment_method', '!=', 'direct_debit')],'readonly': [('payment_method', '!=', 'direct_debit')], 'required': [('payment_method', '=', 'direct_debit')]} " />
<field name="end_date" string="To" attrs="{'invisible': [('payment_method', '!=', 'direct_debit')]}" readonly="1" />
<field name="donation_amount" attrs="{'readonly':[('fixed_value','=',True)]}" required="1" />
<field name="total_donation_amount" readonly="1"/>
@ -387,28 +296,25 @@
<field name="sequence" invisible="1" />
<field name="state" invisible="1" />
<field name="allowed_payment_method_ids" invisible="1" />
<field name="sequence_no" />
<field name="donation_type"
attrs="{'invisible': [('parent.record_type', '!=', 'sponsorship')], 'readonly': [('parent.record_type', '=', 'sponsorship')]}"
force_save="1" />
<field name="sequence_no" invisible="1" />
<field name="donation_type" invisible="1"/>
<field name="payment_method" invisible="1" />
<field name="hide_beneficiary_group" invisible="1" />
<field name="payment_option" invisible="1"/>
<field name="sponsorship_duration"
attrs="{'invisible': [('donation_type','!=','sponsorship')], 'required': [('donation_type','=','sponsorship')]}" />
<field name="product_template_id" />
<field name="payment_method_id" required="1"/>
<field name="donation_types"
attrs="{'invisible': [('parent.record_type', '!=', 'donation')], 'required': [('parent.record_type', '=', 'donation')]}" />
<field name="payment_option"
attrs="{'invisible': [('sponsorship_duration','!=','temporary')], 'required': [('sponsorship_duration','=','temporary')]}"
readonly="1" force_save="1" />
<field name="payment_month_count"
attrs="{'invisible': [('sponsorship_duration','!=','temporary'), ('payment_method', '!=', 'direct_debit')], 'required': [('payment_method', '!=', 'direct_debit')]}" />
<field name="start_date" string="Start Date"
attrs="{'invisible': [('sponsorship_duration', '!=', 'temporary'), ('payment_method', '!=', 'direct_debit')], 'required': [('payment_method', '=', 'direct_debit')]}" />
attrs="{'invisible': [('sponsorship_duration', '!=', 'temporary'), ('payment_method', '!=', 'direct_debit')], 'required': [('payment_method', '=', 'direct_debit')], 'readonly': [('payment_method', '!=', 'direct_debit')],}" />
<field name="end_date" string="End Date" readonly="1"
attrs="{'invisible': [('sponsorship_duration', '!=', 'temporary'), ('payment_method', '!=', 'direct_debit')]}" />
</group>
<group>
<field name="product_template_id" />
<field name="donation_mechanism"
attrs="{
'invisible':[('donation_type','not in',['donation', 'waqf'])],
@ -424,28 +330,13 @@
attrs="{'invisible':[('sponsorship_type','!=','group')]}" />
<field name="name" />
</group>
</group>
<group string="Benefit Details"
attrs="{'invisible': [('donation_mechanism','!=','with_conditions')]}">
<group>
<field name="members_domain_ids" invisible="1" />
<group attrs="{'invisible': ['|', ('donation_mechanism','!=','with_conditions'), ('hide_beneficiary_group','=', True)]}">
<group string="Beneficiary Filters" attrs="{'invisible': [('sponsorship_type','=','group'), ('parent.record_type','=','donation')]}">
<field name="sponsorship_type"
attrs="{'invisible': [('donation_mechanism','!=','with_conditions')], 'required': [('donation_mechanism','=','with_conditions')]}" />
attrs="{'invisible': [('donation_mechanism','!=','with_conditions')], 'required': [('hide_beneficiary_group','=', False), ('donation_mechanism','=','with_conditions')]}" />
<field name="benefit_type"
attrs="{'invisible': [('donation_mechanism','!=','with_conditions')], 'required': [('donation_mechanism','=','with_conditions')]}" />
<field name="benefit_id"
attrs="{'invisible': ['|', ('sponsorship_type','!=','person'), ('donation_mechanism','!=','with_conditions')], 'required': [('members_domain_ids', '!=', []), ('sponsorship_type','=','person'), ('donation_mechanism','=','with_conditions'), ('state', 'in', ['active', 'closed', 'extended'])]}"
options="{'no_create': True, 'no_create_edit':True, 'no_open': True}" />
<field name="family_id"
attrs="{'invisible': [('sponsorship_type','=','group'), ('parent.record_type','=','sponsorship')],
'readonly': ['|', ('sponsorship_type', '!=', 'group'), ('parent.record_type','!=','donation')],
'required': [('sponsorship_type', '=','group'), ('parent.record_type','=','donation')]}"
groups="odex_takaful.sponsorship_system_manager_group" />
</group>
<group
attrs="{'invisible': [('sponsorship_type','=','group'), ('parent.record_type','=','donation')]}">
attrs="{'invisible': [('donation_mechanism','!=','with_conditions')], 'required': [('hide_beneficiary_group','=', False), ('donation_mechanism','=','with_conditions')]}" />
<field name="gender"
attrs="{'invisible': [('donation_mechanism','!=','with_conditions')]}" />
<field name="age_category_id"
@ -459,19 +350,30 @@
<field name="benefit_family_code"
attrs="{'invisible': [('donation_mechanism','!=','with_conditions')]}" />
</group>
<group>
<field name="members_domain_ids" invisible="1" />
<field name="benefit_id"
attrs="{'invisible': ['|', ('sponsorship_type','!=','person'), ('donation_mechanism','!=','with_conditions')], 'required': [('members_domain_ids', '!=', []), ('sponsorship_type','=','person'), ('hide_beneficiary_group','=', False), ('donation_mechanism','=','with_conditions'), ('state', 'in', ['active', 'closed', 'extended'])]}"
options="{'no_create': True, 'no_create_edit':True, 'no_open': True}" />
<field name="family_id"
attrs="{'invisible': [('sponsorship_type','=','group'), ('parent.record_type','=','sponsorship')],
'readonly': ['|', ('sponsorship_type', '!=', 'group'), ('parent.record_type','!=','donation')],
'required': [('hide_beneficiary_group','=', False),('sponsorship_type', '=','group'), ('parent.record_type','=','donation')]}"
groups="odex_takaful.sponsorship_system_manager_group" />
</group>
</group>
<group string="Orphans List"
attrs="{'invisible': ['|', '|',('parent.record_type','!=','sponsorship'), ('sponsorship_type', '!=', 'group'), ('benefit_type', '!=', 'orphan')]}">
attrs="{'invisible': ['|', '|', '|', ('hide_beneficiary_group','=', True), ('parent.record_type','!=','sponsorship'), ('sponsorship_type', '!=', 'group'), ('benefit_type', '!=', 'orphan')]}">
<field name="benefit_ids" nolabel="1"
domain="[('id', 'in', members_domain_ids)]" />
</group>
<group string="Widows List"
attrs="{'invisible': ['|', '|',('parent.record_type','!=','sponsorship'), ('sponsorship_type', '!=', 'group'), ('benefit_type', '!=', 'widow')]}">
attrs="{'invisible': ['|', '|', '|', ('hide_beneficiary_group','=', True), ('parent.record_type','!=','sponsorship'), ('sponsorship_type', '!=', 'group'), ('benefit_type', '!=', 'widow')]}">
<field name="benefit_ids" nolabel="1"
domain="[('id', 'in', members_domain_ids)]" />
</group>
<group string="Orphans and Widows List"
attrs="{'invisible': ['|', '|',('parent.record_type','!=','sponsorship'), ('sponsorship_type', '!=', 'group'), ('benefit_type', '!=', 'both')]}">
attrs="{'invisible': ['|', '|', '|', ('hide_beneficiary_group','=', True), ('parent.record_type','!=','sponsorship'), ('sponsorship_type', '!=', 'group'), ('benefit_type', '!=', 'both')]}">
<field name="benefit_ids" nolabel="1"
domain="[('id', 'in', members_domain_ids)]" />
</group>

View File

@ -97,6 +97,7 @@
<field placeholder="Second Name" name="second_name" class="oe_inline"/>
<field placeholder="Third Name" name="middle_name" class="oe_inline"/>
<field placeholder="Family Name" name="family_name" class="oe_inline"/>
<field placeholder="Suffix Title" name="suffix_title_id" class="oe_inline"/>
</h2>
</div>
@ -214,7 +215,7 @@
<field name="name">The Sponsor</field>
<field name="res_model">takaful.sponsor</field>
<field name="view_mode">tree,form</field>
<field name="context">{'default_company_type': 'person'}</field>
<field name="context">{'default_company_type': 'person', 'is_benefit': True}</field>
</record>
<record id="active_sponsor_report_pivot_view" model="ir.ui.view">

View File

@ -59,7 +59,8 @@ class Partner(models.Model):
is_vendor = fields.Boolean()
is_donor = fields.Boolean()
code = fields.Char(string="Code", copy=False)
sponsor_title = fields.Many2one('res.partner.title',string='Title')
suffix_title_id = fields.Many2one('res.partner.title',string='Suffix Title')
company_type = fields.Selection(selection_add=[('charity', _('Charity'))])
first_name = fields.Char(string="First Name", tracking=True)
second_name = fields.Char(string="Second Name", tracking=True)
@ -151,22 +152,31 @@ class Partner(models.Model):
_logger.info("-> Partner account type migration finished.")
return True
# @api.depends('father_family_name')
# def get_partner_name(self):
# for rec in self:
# if rec.father_family_name:
# rec.name = rec.father_family_name
@api.depends('company_type', 'first_name', 'second_name', 'middle_name', 'family_name', 'father_name',
'father_second_name', 'father_third_name', 'father_family_name')
@api.depends('company_type',
'first_name',
'second_name',
'middle_name',
'family_name',
'sponsor_title',
'suffix_title_id')
def get_partner_name(self):
for rec in self:
if self.env.context.get('is_benefit', False):
if rec.company_type == 'person':
rec.name = ''
if all([rec.second_name, rec.first_name, rec.middle_name, rec.family_name]):
rec.name = rec.first_name + " " + rec.second_name + " " + rec.middle_name + " " + rec.family_name
elif all([rec.father_name, rec.father_second_name, rec.father_third_name, rec.father_family_name]):
rec.name = rec.father_name + " " + rec.father_second_name + " " + rec.father_third_name + " " + rec.father_family_name
names = []
if rec.sponsor_title:
names.append(f"{rec.sponsor_title.shortcut if rec.sponsor_title.shortcut else rec.sponsor_title.name}/")
if rec.first_name:
names.append(rec.first_name)
if rec.second_name:
names.append(rec.second_name)
if rec.middle_name:
names.append(rec.middle_name)
if rec.family_name:
names.append(rec.family_name)
if rec.suffix_title_id:
names.append(f"({rec.suffix_title_id.shortcut if rec.suffix_title_id.shortcut else rec.suffix_title_id.name})")
rec.name = " ".join(names)
else:
rec.second_name = ''
rec.first_name = ''
@ -243,3 +253,9 @@ class Partner(models.Model):
return False
else:
return False
class PartnerTitle(models.Model):
_inherit = 'res.partner.title'
position = fields.Selection([('prefix', 'Prefix'), ('suffix', 'Suffix')], default='prefix')

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="inherit_view_id_inherit_module_name" model="ir.ui.view">
<field name="name">model.name.view.form.inherit</field>
<field name="model">model.name</field>
<field name="inherit_id" ref="inherit_module_name.inherit_view_id"/>
<field name="arch" type="xml">
</field>
</record>
</odoo>