Skip to content

Commit 22a98e2

Browse files
Merge pull request #1 from OpenSPP/fix-cycle-approve-and-auto-approve-entitlement
Fixed cycle approve and entitlement's auto approve
2 parents 76714db + ce2f65c commit 22a98e2

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

g2p_programs/models/cycle.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,6 @@ def approve(self):
285285
entitlement_manager = rec.program_id.get_manager(constants.MANAGER_ENTITLEMENT)
286286
if not entitlement_manager:
287287
raise UserError(_("No Entitlement Manager defined."))
288-
rec.write(
289-
{
290-
"approved_date": fields.Datetime.now(),
291-
"approved_by": self.env.user.id,
292-
"state": self.STATE_APPROVED,
293-
}
294-
)
295288
return cycle_manager.approve_cycle(
296289
rec,
297290
auto_approve=cycle_manager.auto_approve_entitlements,

g2p_programs/models/managers/cycle_manager.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,13 @@ def approve_cycle(self, cycle, auto_approve=False, entitlement_manager=None):
110110
"""
111111
# Check if user is allowed to approve the cycle
112112
if cycle.state == "to_approve":
113-
cycle.update({"state": "approved"})
113+
cycle.update(
114+
{
115+
"approved_date": fields.Datetime.now(),
116+
"approved_by": self.env.user.id,
117+
"state": cycle.STATE_APPROVED,
118+
}
119+
)
114120
# Running on_state_change because it is not triggered automatically with rec.update above
115121
self.on_state_change(cycle)
116122
else:

0 commit comments

Comments
 (0)