diff --git a/g2p_programs/models/accounting/fund_management.py b/g2p_programs/models/accounting/fund_management.py index 0b905ff8..661b2767 100644 --- a/g2p_programs/models/accounting/fund_management.py +++ b/g2p_programs/models/accounting/fund_management.py @@ -42,7 +42,11 @@ class ProgramFundManagement(models.Model): @api.ondelete(at_uninstall=False) def _unlink_fund(self): - if self.state == "posted": + count_posted_fund = 0 + for record in self: + if record.state == "posted": + count_posted_fund += 1 + if count_posted_fund > 0: raise UserError(_("This fund is already posted and cannot be deleted.")) def post_fund(self):