From 95cccd6c7df1c4ab88e75a536f217e77ab850dee Mon Sep 17 00:00:00 2001 From: Dibik Date: Wed, 27 Mar 2024 02:16:47 +0530 Subject: [PATCH] G2P-1803: Added Reimbursement import service provider --- g2p_program_reimbursement/models/__init__.py | 1 + .../models/eligibility_manager.py | 17 +++++++++++++++++ .../wizard/create_program_wizard.py | 3 +++ 3 files changed, 21 insertions(+) create mode 100644 g2p_program_reimbursement/models/eligibility_manager.py 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"])