diff --git a/g2p_programs/models/cycle.py b/g2p_programs/models/cycle.py index 1a488a8d..76c4100d 100644 --- a/g2p_programs/models/cycle.py +++ b/g2p_programs/models/cycle.py @@ -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, diff --git a/g2p_programs/models/managers/cycle_manager.py b/g2p_programs/models/managers/cycle_manager.py index 964f0562..0626bbc2 100644 --- a/g2p_programs/models/managers/cycle_manager.py +++ b/g2p_programs/models/managers/cycle_manager.py @@ -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: