WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@elshafei-developer
Copy link
Contributor

@elshafei-developer elshafei-developer commented Dec 2, 2025

Problem

In the Additional Salary DocType, the class AdditionalSalary defines a method named validate_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_submit is 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 AdditionalSalary class redefines a method with the same name, the core validation is silently bypassed, meaning
Fields 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 AdditionalSalary was renamed from
validate_update_after_submitbefore_update_after_submit

before_update_after_submit is 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

  • Chores
    • Renamed an internal post-submission validation hook for additional salary handling. Behavior unchanged: overlap validation still runs unless disabled, so there are no user-facing changes.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 2, 2025

Walkthrough

A method in the AdditionalSalary class within hrms/payroll/doctype/additional_salary/additional_salary.py has been renamed from validate_update_after_submit() to before_update_after_submit(). The method continues to call validate_recurring_additional_salary_overlap() when not disabled, preserving previous behavior. No other logic changes were introduced.

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately captures the main change: renaming a hook method from validate_update_after_submit to before_update_after_submit, which is the primary fix in this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 to on_update_after_submit correctly restores core validation while preserving custom overlap checks

Switching from validate_update_after_submit to on_update_after_submit stops overriding the core Document.validate_update_after_submit logic and instead uses the intended post-update hook, matching the pattern in salary_structure_assignment.py (Lines 31-32 in that file). The existing behavior—revalidating recurring overlaps when the record remains enabled—is preserved via the if not self.disabled guard, 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() via on_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

📥 Commits

Reviewing files that changed from the base of the PR and between 0e5f64b and a349410.

📒 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

@ruchamahabal ruchamahabal changed the title fix: rename validate_update_after_submit to on_update_after_submit fix(Additional Salary): change validate_update_after_submit hook to before_update_after_submit Dec 9, 2025
@ruchamahabal ruchamahabal merged commit 0af694b into frappe:develop Dec 9, 2025
10 checks passed
mergify bot pushed a commit that referenced this pull request Dec 9, 2025
… `before_update_after_submit` (#3792)

Co-authored-by: Rucha Mahabal <[email protected]>
(cherry picked from commit 0af694b)
ruchamahabal added a commit that referenced this pull request Dec 9, 2025
… `before_update_after_submit` (#3792) (#3831)

Co-authored-by: El-Shafei H. <[email protected]>
Co-authored-by: Rucha Mahabal <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants