diff --git a/g2p_program_reimbursement/models/__init__.py b/g2p_program_reimbursement/models/__init__.py index 3569aa99..f865559b 100644 --- a/g2p_program_reimbursement/models/__init__.py +++ b/g2p_program_reimbursement/models/__init__.py @@ -3,3 +3,4 @@ from . import entitlement from . import cycle from . import entitlement_manager +from . import eligibility_manager diff --git a/g2p_program_reimbursement/models/eligibility_manager.py b/g2p_program_reimbursement/models/eligibility_manager.py new file mode 100644 index 00000000..858724c3 --- /dev/null +++ b/g2p_program_reimbursement/models/eligibility_manager.py @@ -0,0 +1,17 @@ +from odoo import models + + +class G2PDefaultEligibilityManager(models.Model): + _inherit = "g2p.program_membership.manager.default" + + def _prepare_eligible_domain(self, membership=None): + domain = super()._prepare_eligible_domain(membership) + if self.env.context.get("is_reimbursement_program"): + domain = [] + domain = [ + ("supplier_rank", ">", 0), + ("is_group", "=", False), + ("is_registrant", "=", False), + ] + return domain + return domain diff --git a/g2p_program_reimbursement/wizard/create_program_wizard.py b/g2p_program_reimbursement/wizard/create_program_wizard.py index c8b52bb8..69c9e2a4 100644 --- a/g2p_program_reimbursement/wizard/create_program_wizard.py +++ b/g2p_program_reimbursement/wizard/create_program_wizard.py @@ -7,6 +7,9 @@ class G2PCreateNewReimbursementProgramWiz(models.TransientModel): is_reimbursement_program = fields.Boolean(default=False) def create_program(self): + if self.is_reimbursement_program: + self.env.context = {"is_reimbursement_program": True} + res = super(G2PCreateNewReimbursementProgramWiz, self).create_program() for rec in self: program = self.env["g2p.program"].browse(res["res_id"])