Skip to content

Commit

Permalink
Fixed cycle approve and entitlement's auto approve
Browse files Browse the repository at this point in the history
  • Loading branch information
reichie020212 authored and mkumar-02 committed Oct 17, 2024
1 parent 46f31a4 commit 2fe68c1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 0 additions & 7 deletions g2p_programs/models/cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,6 @@ def approve(self):
entitlement_manager = rec.program_id.get_manager(constants.MANAGER_ENTITLEMENT)
if not entitlement_manager:
raise UserError(_("No Entitlement Manager defined."))
rec.write(
{
"approved_date": fields.Datetime.now(),
"approved_by": self.env.user.id,
"state": self.STATE_APPROVED,
}
)
return cycle_manager.approve_cycle(
rec,
auto_approve=cycle_manager.auto_approve_entitlements,
Expand Down
8 changes: 7 additions & 1 deletion g2p_programs/models/managers/cycle_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,13 @@ def approve_cycle(self, cycle, auto_approve=False, entitlement_manager=None):
"""
# Check if user is allowed to approve the cycle
if cycle.state == "to_approve":
cycle.update({"state": "approved"})
cycle.update(
{
"approved_date": fields.Datetime.now(),
"approved_by": self.env.user.id,
"state": cycle.STATE_APPROVED,
}
)
# Running on_state_change because it is not triggered automatically with rec.update above
self.on_state_change(cycle)
else:
Expand Down

0 comments on commit 2fe68c1

Please sign in to comment.