Skip to content

Commit

Permalink
G2P-1266: Added latest PMT Score field
Browse files Browse the repository at this point in the history
Signed-off-by: mkumar-02 <[email protected]>
  • Loading branch information
mkumar-02 committed Jul 3, 2024
1 parent 2483e55 commit d806a9d
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion g2p_proxy_means_test/models/program_registrant_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@
class G2PProgramRegistrantInfo(models.Model):
_inherit = "g2p.program.registrant_info"

pmt_score = fields.Float("PMT Score", compute="_compute_pmt_score", store=True)
program_pmt_config = fields.Boolean(related="program_id.pmt_config", readonly=True)
pmt_score = fields.Float("PMT Score", compute="_compute_pmt_score", store=True)
latest_registrant_info = fields.Many2one(
"g2p.program.registrant_info", compute="_compute_latest_registrant_info"
)
latest_pmt_score = fields.Float(
related="latest_registrant_info.pmt_score", string="Latest PMT Score", store=True
)

@api.depends(
"program_registrant_info",
Expand All @@ -25,6 +31,19 @@ def _compute_pmt_score(self):

rec.pmt_score = score

def _compute_latest_registrant_info(self):
for rec in self:
if rec.program_id and rec.registrant_id:
reg_info = self.search(
[("program_id", "=", rec.program_id.id), ("registrant_id", "=", rec.registrant_id.id)]
).sorted("create_date", reverse=True)

if reg_info:
reg_info.update({"latest_pmt_score": rec.pmt_score})
rec.latest_registrant_info = reg_info[0]
else:
rec.latest_registrant_info = None

def delete_related_proxy_means_params(self, field):
proxy_params_to_delete = self.env["g2p.proxy_means_test_params"].search([("pmt_field", "=", field)])
for param in proxy_params_to_delete:
Expand Down

0 comments on commit d806a9d

Please sign in to comment.