diff --git a/g2p_program_cycleless/models/program_manager.py b/g2p_program_cycleless/models/program_manager.py index 7174a76a..8a87607b 100644 --- a/g2p_program_cycleless/models/program_manager.py +++ b/g2p_program_cycleless/models/program_manager.py @@ -11,7 +11,7 @@ class DefaultProgramManager(models.Model): @api.constrains("is_cycleless") def onchange_is_cycless(self): orig_prog_man = self.program_id.get_manager(constants.MANAGER_PROGRAM) - if self.id == orig_prog_man.id: + if orig_prog_man and self.id == orig_prog_man.id: self.program_id.is_cycleless = self.is_cycleless if self.is_cycleless and not self.program_id.default_active_cycle: self.program_id.create_new_cycle() diff --git a/g2p_programs/models/managers/cycle_manager.py b/g2p_programs/models/managers/cycle_manager.py index f25ac310..964f0562 100644 --- a/g2p_programs/models/managers/cycle_manager.py +++ b/g2p_programs/models/managers/cycle_manager.py @@ -17,7 +17,7 @@ class CycleManager(models.Model): _description = "Cycle Manager" _inherit = "g2p.manager.mixin" - program_id = fields.Many2one("g2p.program", "Program") + program_id = fields.Many2one("g2p.program", "Program", ondelete="cascade") @api.model def _selection_manager_ref_id(self): diff --git a/g2p_programs/models/managers/deduplication_manager.py b/g2p_programs/models/managers/deduplication_manager.py index db774da5..98b39a1f 100644 --- a/g2p_programs/models/managers/deduplication_manager.py +++ b/g2p_programs/models/managers/deduplication_manager.py @@ -14,7 +14,7 @@ class DeduplicationManager(models.Model): _description = "Deduplication Manager" _inherit = "g2p.manager.mixin" - program_id = fields.Many2one("g2p.program", "Program") + program_id = fields.Many2one("g2p.program", "Program", ondelete="cascade") @api.model def _selection_manager_ref_id(self): diff --git a/g2p_programs/models/managers/eligibility_manager.py b/g2p_programs/models/managers/eligibility_manager.py index bb35c0eb..b4aa23bf 100644 --- a/g2p_programs/models/managers/eligibility_manager.py +++ b/g2p_programs/models/managers/eligibility_manager.py @@ -13,7 +13,7 @@ class EligibilityManager(models.Model): _description = "Eligibility Manager" _inherit = "g2p.manager.mixin" - program_id = fields.Many2one("g2p.program", "Program") + program_id = fields.Many2one("g2p.program", "Program", ondelete="cascade") @api.model def _selection_manager_ref_id(self): diff --git a/g2p_programs/models/managers/entitlement_manager.py b/g2p_programs/models/managers/entitlement_manager.py index 998c342f..b86ecb1c 100644 --- a/g2p_programs/models/managers/entitlement_manager.py +++ b/g2p_programs/models/managers/entitlement_manager.py @@ -13,7 +13,7 @@ class EntitlementManager(models.Model): _description = "Entitlement Manager" _inherit = "g2p.manager.mixin" - program_id = fields.Many2one("g2p.program", "Program") + program_id = fields.Many2one("g2p.program", "Program", ondelete="cascade") @api.model def _selection_manager_ref_id(self): diff --git a/g2p_programs/models/managers/notification_manager.py b/g2p_programs/models/managers/notification_manager.py index f213c7eb..a20cac79 100644 --- a/g2p_programs/models/managers/notification_manager.py +++ b/g2p_programs/models/managers/notification_manager.py @@ -7,7 +7,7 @@ class Notification(models.Model): _description = "Program Notification Manager" _inherit = "g2p.manager.mixin" - program_id = fields.Many2one("g2p.program", "Program") + program_id = fields.Many2one("g2p.program", "Program", ondelete="cascade") @api.model def _selection_manager_ref_id(self): diff --git a/g2p_programs/models/managers/payment_manager.py b/g2p_programs/models/managers/payment_manager.py index b79459e5..8ef51373 100644 --- a/g2p_programs/models/managers/payment_manager.py +++ b/g2p_programs/models/managers/payment_manager.py @@ -18,7 +18,7 @@ class PaymentManager(models.Model): _description = "Payment Manager" _inherit = "g2p.manager.mixin" - program_id = fields.Many2one("g2p.program", "Program") + program_id = fields.Many2one("g2p.program", "Program", ondelete="cascade") @api.model def _selection_manager_ref_id(self): diff --git a/g2p_programs/models/managers/program_manager.py b/g2p_programs/models/managers/program_manager.py index 82e43ffc..189d568e 100644 --- a/g2p_programs/models/managers/program_manager.py +++ b/g2p_programs/models/managers/program_manager.py @@ -17,7 +17,7 @@ class ProgramManager(models.Model): _description = "Program Manager" _inherit = "g2p.manager.mixin" - program_id = fields.Many2one("g2p.program", "Program") + program_id = fields.Many2one("g2p.program", "Program", ondelete="cascade") @api.model def _selection_manager_ref_id(self):