Skip to content

fix(MOMFollowup): use proper workflow API in auto-escalation schedule…#6028

Open
pjamsheer wants to merge 3 commits into
version-15from
18163
Open

fix(MOMFollowup): use proper workflow API in auto-escalation schedule…#6028
pjamsheer wants to merge 3 commits into
version-15from
18163

Conversation

@pjamsheer
Copy link
Copy Markdown
Contributor

…d job

This pull request improves the mom_followup_reminder function in mom_followup.py to make the MOM follow-up escalation process more robust and auditable. The main changes include using the workflow system for state transitions, auto-populating missing reasons for escalation, temporarily elevating permissions to perform workflow actions, and adding error handling and logging.

Enhancements to MOM Follow-up Escalation:

  • The function now uses apply_workflow to transition the document state instead of directly setting the workflow_state, ensuring proper workflow tracking and auditability.
  • If the "reason for missed MOM" is not provided, it is auto-populated with a standard message during escalation.
  • The code temporarily elevates permissions to "Administrator" to bypass role validation when applying the workflow, then restores the original user context.

Error handling improvements:

  • Added a try/except block to log any errors that occur during the escalation process, making failures easier to diagnose.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the scheduled mom_followup_reminder escalation logic to transition MOM Followup documents via the workflow system (instead of directly setting workflow_state), while also attempting to auto-fill a missing “reason for missed MOM” and improving error logging for failed escalations.

Changes:

  • Switch escalation from direct workflow_state assignment to apply_workflow(...) for auditable workflow transitions.
  • Auto-populate reason_for_missed_mom when missing during auto-escalation.
  • Add try/except logging around each escalation attempt and temporarily elevate permissions for workflow actions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread one_fm/operations/doctype/mom_followup/mom_followup.py
Comment thread one_fm/operations/doctype/mom_followup/mom_followup.py
Comment thread one_fm/operations/doctype/mom_followup/mom_followup.py Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread one_fm/operations/doctype/mom_followup/mom_followup.py Outdated
pjamsheer and others added 3 commits April 29, 2026 18:01
…d job

Replace direct workflow_state assignment with apply_workflow to properly
handle role validation and workflow conditions. Elevate to Administrator
context and auto-populate reason_for_missed_mom field.

Fixes: WorkflowPermissionError in mom_followup_reminder

Co-authored-by: Copilot <copilot@github.com>
… restoration in reminder function

Co-authored-by: Copilot <copilot@github.com>
… with role bypass

Co-authored-by: Copilot <copilot@github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread one_fm/operations/doctype/mom_followup/mom_followup.py
@pjamsheer pjamsheer requested a review from samdanikouser April 29, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants