FIX Donation Line and Replacement button visible
This commit is contained in:
parent
2649c2947c
commit
0618cb2ffb
|
|
@ -87,6 +87,7 @@ class DonationsDetailsLines(models.Model):
|
|||
replacement_count = fields.Integer(string='Replacement', compute='_compute_replacement_count')
|
||||
|
||||
show_extend_button = fields.Boolean(string='Show Extend Button', compute='_compute_show_extend_button')
|
||||
show_replaced_button = fields.Boolean(string='Show Replaced Button', compute='_compute_show_replaced_button')
|
||||
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')
|
||||
|
|
@ -135,6 +136,15 @@ class DonationsDetailsLines(models.Model):
|
|||
)
|
||||
rec.show_extend_button = show_extend_button
|
||||
|
||||
@api.depends('donation_mechanism', 'state')
|
||||
def _compute_show_replaced_button(self):
|
||||
for rec in self:
|
||||
show_replaced_button = (
|
||||
((rec.record_type == 'donation' and rec.donation_mechanism == 'with_conditions') or rec.record_type == 'sponsorship') and
|
||||
rec.state in ('active', 'paid','replace')
|
||||
)
|
||||
rec.show_replaced_button = show_replaced_button
|
||||
|
||||
@api.depends('sponsorship_duration', 'direct_debit', 'record_type', 'start_date')
|
||||
def _compute_hide_beneficiary_group(self):
|
||||
for rec in self:
|
||||
|
|
|
|||
|
|
@ -1174,32 +1174,33 @@ class TakafulSponsorship(models.Model):
|
|||
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)
|
||||
elif line.benefit_ids == 1:
|
||||
line.benefit_id = line.benefit_ids[0].id
|
||||
if self.record_type == 'sponsorship':
|
||||
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 = {
|
||||
'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',
|
||||
}
|
||||
self.write({'donations_details_lines_mechanism_ids': [(0, 0, new_vals)]})
|
||||
|
||||
elif len(line.benefit_ids) == 1:
|
||||
line.benefit_id = line.benefit_ids[0].id
|
||||
|
||||
all_donation_lines = (self.donations_details_lines + self.donations_details_lines_mechanism_ids).filtered(
|
||||
lambda r: r.display_type == False)
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@
|
|||
name="action_view_replacement_wizard"
|
||||
type="object"
|
||||
class="btn-primary"
|
||||
attrs="{'invisible': ['|', '&',('state', 'not in', ['active', 'paid', 'replace']), ('record_type', '=', 'donation'), ('donation_mechanism', '=', 'without_conditions')]}"
|
||||
attrs="{'invisible': [('show_replaced_button', '=', False)]}"
|
||||
groups="odex_takaful.group_orphan_replacement" />
|
||||
<button string="Replace Sponsor"
|
||||
name="replace_sponsor_wizard"
|
||||
|
|
@ -185,6 +185,7 @@
|
|||
<field name="parent_state" invisible="1" />
|
||||
<field name="is_paid" invisible="1" />
|
||||
<field name="show_extend_button" invisible="1" />
|
||||
<field name="show_replaced_button" invisible="1" />
|
||||
</group>
|
||||
</group>
|
||||
|
||||
|
|
|
|||
|
|
@ -286,6 +286,7 @@
|
|||
<field name="sponsorships_computed" invisible="1"/>
|
||||
<field name="sponsorship_scheduling_line_ids" invisible="1"/>
|
||||
<field name="show_extend_button" invisible="1"/>
|
||||
<field name="show_replaced_button" invisible="1"/>
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="display_type" invisible="1"/>
|
||||
<field name="state" invisible="1"/>
|
||||
|
|
@ -368,7 +369,7 @@
|
|||
string="Orphan Replacement"
|
||||
type="object"
|
||||
class="btn-primary"
|
||||
attrs="{'invisible': [('state', 'not in', ['active', 'paid'])]}"
|
||||
attrs="{'invisible': [('show_replaced_button', '=', False)]}"
|
||||
groups="odex_takaful.group_orphan_replacement"/>
|
||||
|
||||
<!-- <button name="action_register_payment"
|
||||
|
|
@ -384,7 +385,7 @@
|
|||
string="Orphan Replacement"
|
||||
type="object"
|
||||
class="btn-primary"
|
||||
attrs="{'invisible': [('state', '!=', 'active')]}"
|
||||
attrs="{'invisible': [('show_replaced_button', '=', False)]}"
|
||||
groups="odex_takaful.group_orphan_replacement"/>
|
||||
<button name="action_extend_sponsorship"
|
||||
string="Extend"
|
||||
|
|
@ -404,6 +405,7 @@
|
|||
<field name="sequence" invisible="1"/>
|
||||
<field name="state" invisible="1"/>
|
||||
<field name="show_extend_button" invisible="1"/>
|
||||
<field name="show_replaced_button" invisible="1"/>
|
||||
<field name="sequence_no" invisible="1"/>
|
||||
<field name="donation_type" invisible="1"/>
|
||||
<field name="direct_debit" invisible="1"/>
|
||||
|
|
|
|||
|
|
@ -72,8 +72,9 @@ class ReplacementWiz(models.TransientModel):
|
|||
_name = 'replacement.wiz'
|
||||
_description = "Replace Wizard"
|
||||
|
||||
family_domain_ids = fields.Many2many('family.member', compute='_compute_family_domain_ids')
|
||||
old_family_id = fields.Many2one('grant.benefit', string='Old Family',readonly=True)
|
||||
new_family_id = fields.Many2one('grant.benefit', string='New Family', )
|
||||
new_family_id = fields.Many2one('grant.benefit', string='New Family',domain="[('id', 'in', family_domain_ids)]" )
|
||||
old_members_id = fields.Many2one('family.member',string="Old Benefit", readonly=True)
|
||||
members_domain_ids = fields.Many2many('family.member', compute='_compute_members_domain_ids')
|
||||
new_members_id = fields.Many2one('family.member', string="New Benefit", domain="[('id', 'in', members_domain_ids)]")
|
||||
|
|
@ -95,6 +96,22 @@ class ReplacementWiz(models.TransientModel):
|
|||
('under_study_age', 'Under Study Age')])
|
||||
replacement_line_ids = fields.One2many('replacement.line', 'wiz_id', string="Replacement Lines")
|
||||
|
||||
@api.depends('old_family_id')
|
||||
def _compute_family_domain_ids(self):
|
||||
for rec in self:
|
||||
domain = []
|
||||
if rec.record_type == 'donation':
|
||||
domain = [
|
||||
'|',
|
||||
('state', '=', 'second_approve'),
|
||||
'&',
|
||||
('state', 'in', ('waiting_approve', 'first_approve')),
|
||||
('action_type', '=', 'suspended'),
|
||||
('id', '!=',rec.old_family_id.id),]
|
||||
family = self.env['grant.benefit'].sudo().search(domain)
|
||||
|
||||
rec.family_domain_ids = [(6, 0, family.ids)] if family else False
|
||||
|
||||
@api.depends('old_members_id')
|
||||
def _compute_members_domain_ids(self):
|
||||
for rec in self:
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
<group>
|
||||
<field name="record_type" invisible="1"/>
|
||||
<field name="members_domain_ids" invisible="1" />
|
||||
<field name="family_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, 'no_open': True}"/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue