fix(healthcare): prevent false "Not Saved" state in Diagnostic Report after Frappe update#1042
fix(healthcare): prevent false "Not Saved" state in Diagnostic Report after Frappe update#1042md-umair-21 wants to merge 1 commit into
Conversation
… after Frappe update
WalkthroughIn 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Issue:-
After upgrading to the latest Frappe/ERPNext version, opening an already approved Diagnostic Report was showing the form in an unsaved state even though no user changes had been made.
Testing
This was causing confusion because:
Root Cause:-
The Diagnostic Report observation widget renders result fields using a custom FieldGroup-based UI.
In newer Frappe versions, field initialization/default hydration during render can trigger the custom result field change handler. That handler was directly calling frm.dirty(), which marked the document as unsaved during initial render instead of only during actual user edits.
As a result, simply loading the Diagnostic Report UI could incorrectly set the form to a dirty state.
Fix
After upgrading to newer Frappe/ERPNext versions, the Observation Widget's result field change event could be triggered during field initialization and value hydration. Since the handler directly called frm.dirty(), approved Diagnostic Reports were incorrectly marked as Not Saved immediately after loading.
This fix adds a render-time guard to ignore change events fired during field initialization. As a result:
Files Changed
Notes
After pulling this change, run:
bench build --app healthcare