Skip to content

Commit

Permalink
Merge pull request #137 from RamakrishnaVellala/15.0-develop-main
Browse files Browse the repository at this point in the history
Following bugs solved
  • Loading branch information
shibu-narayanan authored Oct 30, 2023
2 parents fe2b99c + 7f3479d commit 06a411b
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 5 deletions.
23 changes: 22 additions & 1 deletion g2p_programs/models/cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,32 @@ def unlink(self):
for record in draft_records
):
raise ValidationError(
_("Delete only draft cycles with no approved entitlements.")
_(
"A cycle for which entitlements have been approved cannot be deleted."
)
)
elif all(
record.entitlement_ids.filtered(lambda e: e.state == "draft")
for record in draft_records
):
raise ValidationError(
_(
"Cycle cannot be deleted when Entitlements have been added to the cycle."
)
)
elif draft_records.mapped("cycle_membership_ids"):
raise ValidationError(
_(
"Cycle cannot be deleted when beneficiaries are present in the cycle."
)
)

draft_records.mapped("cycle_membership_ids").unlink()
return super().unlink()
else:
raise ValidationError(
_("Once a cycle has been approved, it cannot be deleted.")
)

raise ValidationError(
_("Delete only draft cycles with no approved entitlements.")
Expand Down
2 changes: 1 addition & 1 deletion g2p_programs/models/cycle_membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class G2PCycleMembership(models.Model):
_name = "g2p.cycle.membership"
_description = "Cycle Membership"
_order = "id desc"
_order = "partner_id asc,id desc"

partner_id = fields.Many2one(
"res.partner", "Registrant", help="A beneficiary", required=True, index=True
Expand Down
2 changes: 1 addition & 1 deletion g2p_programs/models/entitlement.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class G2PEntitlement(models.Model):
_name = "g2p.entitlement"
_description = "Entitlement"
_order = "id desc"
_order = "partner_id asc,id desc"
_check_company_auto = True

@api.model
Expand Down
20 changes: 20 additions & 0 deletions g2p_programs/models/programs.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,3 +552,23 @@ def check_managers_limit(self):
raise UserError(
f"Only one manager can be configured under {combined_message}. Please delete any new manager(s) before saving your changes." # noqa: B950
)

def unlink(self):
managers_to_delete = [
self.eligibility_managers,
self.deduplication_managers,
self.notification_managers,
self.program_managers,
self.cycle_managers,
self.entitlement_managers,
self.payment_managers,
self.reconciliation_managers,
]

for managers in managers_to_delete:
if managers:
for manager in managers:
manager.manager_ref_id.unlink()
managers.unlink()
else:
return super(G2PProgram, self).unlink()
2 changes: 2 additions & 0 deletions g2p_programs/views/managers/cycle_manager_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Part of OpenG2P. See LICENSE file for full copyright and licensing details.
name="program_id"
placeholder="Select a program..."
options="{'no_open':True,'no_create':True,'no_create_edit':True}"
domain="[('state','=','active')]"
/>


Expand Down Expand Up @@ -84,6 +85,7 @@ Part of OpenG2P. See LICENSE file for full copyright and licensing details.
placeholder="Select a program..."
options="{'no_open':True,'no_create':True,'no_create_edit':True}"
invisible="context.get('default_program_id',False)"
domain="[('state','=','active')]"
/>
</h2>
<div class="o_row">
Expand Down
6 changes: 6 additions & 0 deletions g2p_programs/views/managers/deduplication_manager_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Part of OpenG2P. See LICENSE file for full copyright and licensing details.
name="program_id"
placeholder="Select a program..."
options="{'no_open':True,'no_create':True,'no_create_edit':True}"
domain="[('state','=','active')]"
/>
</group>
</sheet>
Expand Down Expand Up @@ -80,6 +81,7 @@ Part of OpenG2P. See LICENSE file for full copyright and licensing details.
placeholder="Select a program..."
options="{'no_open':True,'no_create':True,'no_create_edit':True}"
invisible="context.get('default_program_id',False)"
domain="[('state','=','active')]"
/>
</h2>
<div class="o_row">
Expand Down Expand Up @@ -187,6 +189,7 @@ Part of OpenG2P. See LICENSE file for full copyright and licensing details.
placeholder="Select a program..."
options="{'no_open':True,'no_create':True,'no_create_edit':True}"
invisible="context.get('default_program_id',False)"
domain="[('state','=','active')]"
/>
</h2>
<div class="o_row">
Expand Down Expand Up @@ -301,6 +304,7 @@ Part of OpenG2P. See LICENSE file for full copyright and licensing details.
placeholder="Select a program..."
options="{'no_open':True,'no_create':True,'no_create_edit':True}"
invisible="context.get('default_program_id',False)"
domain="[('state','=','active')]"
/>
</h2>
<div class="o_row">
Expand Down Expand Up @@ -408,6 +412,7 @@ Part of OpenG2P. See LICENSE file for full copyright and licensing details.
placeholder="Select a program..."
options="{'no_open':True,'no_create':True,'no_create_edit':True}"
invisible="context.get('default_program_id',False)"
domain="[('state','=','active')]"
/>
</h2>
<div class="o_row">
Expand Down Expand Up @@ -515,6 +520,7 @@ Part of OpenG2P. See LICENSE file for full copyright and licensing details.
placeholder="Select a program..."
options="{'no_open':True,'no_create':True,'no_create_edit':True}"
invisible="context.get('default_program_id',False)"
domain="[('state','=','active')]"
/>
</h2>
<div class="o_row">
Expand Down
2 changes: 2 additions & 0 deletions g2p_programs/views/managers/eligibility_manager_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Part of OpenG2P. See LICENSE file for full copyright and licensing details.
name="program_id"
placeholder="Select a program..."
options="{'no_open':True,'no_create':True,'no_create_edit':True}"
domain="[('state','=','active')]"
/>
</group>
</sheet>
Expand Down Expand Up @@ -80,6 +81,7 @@ Part of OpenG2P. See LICENSE file for full copyright and licensing details.
placeholder="Select a program..."
options="{'no_open':True,'no_create':True,'no_create_edit':True}"
invisible="context.get('default_program_id',False)"
domain="[('state','=','active')]"
/>
</h2>
<div class="o_row">
Expand Down
2 changes: 2 additions & 0 deletions g2p_programs/views/managers/entitlement_manager_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Part of OpenG2P. See LICENSE file for full copyright and licensing details.
name="program_id"
placeholder="Select a program..."
options="{'no_open':True,'no_create':True,'no_create_edit':True}"
domain="[('state','=','active')]"
/>
</group>
</sheet>
Expand Down Expand Up @@ -85,6 +86,7 @@ Part of OpenG2P. See LICENSE file for full copyright and licensing details.
placeholder="Select a program..."
options="{'no_open':True,'no_create':True,'no_create_edit':True}"
invisible="context.get('default_program_id',False)"
domain="[('state','=','active')]"
/>
</h2>
<div class="o_row">
Expand Down
2 changes: 2 additions & 0 deletions g2p_programs/views/managers/notification_manager_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Part of OpenG2P. See LICENSE file for full copyright and licensing details.
name="program_id"
placeholder="Select a program..."
options="{'no_open':True,'no_create':True,'no_create_edit':True}"
domain="[('state','=','active')]"
/>
</group>
</sheet>
Expand Down Expand Up @@ -80,6 +81,7 @@ Part of OpenG2P. See LICENSE file for full copyright and licensing details.
placeholder="Select a program..."
options="{'no_open':True,'no_create':True,'no_create_edit':True}"
invisible="context.get('default_program_id',False)"
domain="[('state','=','active')]"
/>
</h2>
<div class="o_row">
Expand Down
2 changes: 2 additions & 0 deletions g2p_programs/views/managers/payment_manager_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Part of OpenG2P. See LICENSE file for full copyright and licensing details.
name="program_id"
placeholder="Select a program..."
options="{'no_open':True,'no_create':True,'no_create_edit':True}"
domain="[('state','=','active')]"
/>
</group>
</sheet>
Expand Down Expand Up @@ -82,6 +83,7 @@ Part of OpenG2P. See LICENSE file for full copyright and licensing details.
placeholder="Select a program..."
options="{'no_open':True,'no_create':True,'no_create_edit':True}"
invisible="context.get('default_program_id',False)"
domain="[('state','=','active')]"
/>
</h2>
<div class="o_row">
Expand Down
2 changes: 2 additions & 0 deletions g2p_programs/views/managers/program_manager_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Part of OpenG2P. See LICENSE file for full copyright and licensing details.
name="program_id"
placeholder="Select a program..."
options="{'no_open':True,'no_create':True,'no_create_edit':True}"
domain="[('state','=','active')]"
/>
</group>
</sheet>
Expand Down Expand Up @@ -80,6 +81,7 @@ Part of OpenG2P. See LICENSE file for full copyright and licensing details.
placeholder="Select a program..."
options="{'no_open':True,'no_create':True,'no_create_edit':True}"
invisible="context.get('default_program_id',False)"
domain="[('state','=','active')]"
/>
</h2>
<div class="o_row">
Expand Down
9 changes: 7 additions & 2 deletions g2p_programs/wizard/assign_to_program_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,20 @@ def assign_registrant(self):
)

if len(partner_ids) == 1:
if ig_ctr:
if rec.disabled:
message = _("Disabled group can't be added to the program.") % {
"registrant": rec.name,
"program": self.program_id.name,
}
kind = "danger"
if ig_ctr and not rec.disabled:
message = _(
"%(registrant)s was already in the Program %(program)s"
) % {
"registrant": rec.name,
"program": self.program_id.name,
}
kind = "danger"

else:
if not ctr:
message = (
Expand Down

0 comments on commit 06a411b

Please sign in to comment.