commit
058c121e41
|
|
@ -746,22 +746,6 @@ class DonationsDetailsLines(models.Model):
|
|||
|
||||
record = super(DonationsDetailsLines, self).create(vals)
|
||||
|
||||
if 'benefit_id' in vals and record.sponsorship_id:
|
||||
benefit_name = record.benefit_id.name or 'None'
|
||||
record.sponsorship_id.message_post(
|
||||
body=f"Benefit set to <b>{benefit_name}</b> in a donation item."
|
||||
)
|
||||
if record.record_type == "sponsorship":
|
||||
benefit_ids = record.benefit_ids
|
||||
if benefit_ids and len(benefit_ids) > 1:
|
||||
for count, bf in enumerate(benefit_ids):
|
||||
if count == 0:
|
||||
record.benefit_id = bf.id
|
||||
record.benefit_ids = bf.ids
|
||||
else:
|
||||
new_line_vals = vals.copy()
|
||||
new_line_vals.update({"benefit_ids": bf.ids, "benefit_id": bf.id})
|
||||
new_line_id = self.sudo().create(vals)
|
||||
return record
|
||||
|
||||
def write(self, vals):
|
||||
|
|
|
|||
|
|
@ -1171,11 +1171,38 @@ class TakafulSponsorship(models.Model):
|
|||
_("Please Check The Amount in donation Line!")
|
||||
)
|
||||
|
||||
if not self.code:
|
||||
self.code = self.env['ir.sequence'].sudo().next_by_code('sponsorship.sequence')
|
||||
|
||||
for line in self.donations_details_lines_mechanism_ids:
|
||||
if line.benefit_ids:
|
||||
if len(line.benefit_ids) > 1:
|
||||
for count, bf in enumerate(line.benefit_ids):
|
||||
if count == 0:
|
||||
line.benefit_id = bf.id
|
||||
line.benefit_ids = bf.ids
|
||||
line.benefits_count = 1
|
||||
else:
|
||||
new_vals = {
|
||||
'sponsorship_id': self.id,
|
||||
'benefit_ids': [(6, 0, [bf.id])],
|
||||
'benefit_id': bf.id,
|
||||
'record_type': line.record_type,
|
||||
'sponsorship_duration': line.sponsorship_duration,
|
||||
'product_template_id': line.product_template_id.id,
|
||||
'direct_debit': line.direct_debit,
|
||||
'payment_month_count': line.payment_month_count,
|
||||
'start_date': line.start_date,
|
||||
'donation_amount': line.donation_amount,
|
||||
'payment_option': line.payment_option,
|
||||
'donation_mechanism': 'with_conditions',
|
||||
}
|
||||
new_line = self.env['donations.details.lines'].sudo().create(new_vals)
|
||||
|
||||
all_donation_lines = (self.donations_details_lines + self.donations_details_lines_mechanism_ids).filtered(
|
||||
lambda r: r.display_type == False)
|
||||
|
||||
if not self.code:
|
||||
self.code = self.env['ir.sequence'].sudo().next_by_code('sponsorship.sequence')
|
||||
|
||||
|
||||
for line in all_donation_lines.filtered(lambda r: r.record_type == 'sponsorship'):
|
||||
for benefit in (line.benefit_id | line.benefit_ids):
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@
|
|||
<field name="donation_type" invisible="1"/>
|
||||
<field name="donation_types"
|
||||
attrs="{'invisible': [('donation_type', '!=', 'donation')], 'readonly': [('parent_state', '!=', 'draft')]}" />
|
||||
<field name="product_template_id" attrs="{'readonly': [('parent_state', '!=', 'draft')]}" />
|
||||
<field name="product_template_id" attrs="{'readonly': [('parent_state', '!=', 'draft')]}" options="{'no_create': True, 'no_create_edit':True, 'no_open': True}"/>
|
||||
<field name="product_id" invisible="1" />
|
||||
<field name="donation_mechanism" invisible="1" />
|
||||
<field name="fixed_value" invisible="1" />
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@
|
|||
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)]}"/>
|
||||
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"
|
||||
|
|
@ -298,7 +298,7 @@
|
|||
<!-- 'column_invisible': [('parent.record_type', '!=', 'donation')],-->
|
||||
<!-- 'required': [('parent.record_type', '=', 'donation'), ('display_type', '=', False)]}"/>-->
|
||||
<field name="product_template_id"
|
||||
attrs="{'required': [('display_type', '=', False)]}"/>
|
||||
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"/>
|
||||
|
|
@ -408,7 +408,7 @@
|
|||
<field name="record_type" invisible="1"/>
|
||||
<field name="sponsorship_duration"
|
||||
attrs="{'invisible': [('record_type','!=','sponsorship')], 'required': [('record_type','=','sponsorship')]}"/>
|
||||
<field name="product_template_id"/>
|
||||
<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')]}"/>
|
||||
|
|
|
|||
|
|
@ -121,6 +121,40 @@ class ReplacementWiz(models.TransientModel):
|
|||
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)
|
||||
]])
|
||||
|
||||
|
||||
members = self.env['family.member'].sudo().search(domain)
|
||||
|
||||
rec.members_domain_ids = members if members else self.env['family.member'].sudo().browse()
|
||||
|
|
@ -236,7 +270,7 @@ class ReplacementWiz(models.TransientModel):
|
|||
})
|
||||
|
||||
donation_line.sudo().write({
|
||||
'benefit_ids': [(4, self.new_members_id.id)]
|
||||
'benefit_ids': [(6, 0, [self.new_members_id.id])]
|
||||
})
|
||||
|
||||
old_benefit = self.old_members_id.name
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@
|
|||
<field name="members_domain_ids" invisible="1" />
|
||||
<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}"/>
|
||||
<field name="new_members_id" attrs="{'invisible': [('record_type', '=', 'donation')], 'required': [('record_type', '=', 'sponsorship')]}" options="{'no_create': True, 'no_create_edit':True}"/>
|
||||
<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}"/>
|
||||
</group>
|
||||
|
||||
<group string="Replacement Reason">
|
||||
|
|
|
|||
Loading…
Reference in New Issue