-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix(Additional Salary): change validate_update_after_submit hook to before_update_after_submit
#3792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(Additional Salary): change validate_update_after_submit hook to before_update_after_submit
#3792
Conversation
WalkthroughA method in the Pre-merge checks❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
hrms/payroll/doctype/additional_salary/additional_salary.py (1)
224-226: Renaming toon_update_after_submitcorrectly restores core validation while preserving custom overlap checksSwitching from
validate_update_after_submittoon_update_after_submitstops overriding the coreDocument.validate_update_after_submitlogic and instead uses the intended post-update hook, matching the pattern insalary_structure_assignment.py(Lines 31-32 in that file). The existing behavior—revalidating recurring overlaps when the record remains enabled—is preserved via theif not self.disabledguard, and disabling an overlapping record is still allowed.Given the bug this fixes, it would be good to add regression tests to cover:
- Changing a field without “Allow on Submit” on a submitted Additional Salary now raises the expected validation error.
- Updating a submitted, enabled, recurring Additional Salary still enforces
validate_recurring_additional_salary_overlap()viaon_update_after_submit.I can help sketch these tests against the current Frappe hooks if you’d like.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
hrms/payroll/doctype/additional_salary/additional_salary.py(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
hrms/payroll/doctype/additional_salary/additional_salary.py (1)
hrms/payroll/doctype/salary_structure_assignment/salary_structure_assignment.py (1)
on_update_after_submit(32-33)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Python Unit Tests (1)
- GitHub Check: Python Unit Tests (2)
- GitHub Check: Summary
validate_update_after_submit hook to before_update_after_submit
… `before_update_after_submit` (#3792) Co-authored-by: Rucha Mahabal <[email protected]> (cherry picked from commit 0af694b)
… `before_update_after_submit` (#3792) (#3831) Co-authored-by: El-Shafei H. <[email protected]> Co-authored-by: Rucha Mahabal <[email protected]>
Problem
In the
Additional SalaryDocType, the classAdditionalSalarydefines a method namedvalidate_update_after_submit.However, this method overrides the core method with the same name in the base class
Document.The original
Document.validate_update_after_submitis responsible for enforcing an important validation rule:Any field that does NOT have Allow on Submit must not be changed after submission.
If such a field is changed, Frappe should raise a validation error.
Because the
AdditionalSalaryclass redefines a method with the same name, the core validation is silently bypassed, meaningFields that should NOT be allowed to change after submission were being updated without restriction.
Fix
To restore the expected behavior of the framework
The method in
AdditionalSalarywas renamed fromvalidate_update_after_submit→before_update_after_submitbefore_update_after_submitis the correct hook provided by Frappe for running custom logic before update-on-submit without overriding the core validation function.backport version-15-hotfix
backport version-16-beta
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.