fix: set leave approver on bot-created leave applications - #6
Merged
Conversation
Frappe HR now validates on the server that Leave Approver is set when `leave_approver_mandatory_in_leave_application` is enabled in HR Settings (hrms commit 7ec198aba). The bot builds the Leave Application server-side, so it never got the value the desk form fills in, and every submission failed with "Leave Approver is mandatory". Resolve the approver the same way HR does (Employee.leave_approver, then the department's first approver), and throw a readable message when none is configured for the employee. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
/leave_applicationstarted failing with "Leave Approver is mandatory" after the Frappe HR upgrade. hrms commit7ec198abaadded a server-sidevalidate_leave_approver()check — previously the rule was client-side only, so the bot's server-sidefrappe.get_docnever had to set the field.Solution
Fill
leave_approverthe way the desk form does:Employee.leave_approver, falling back to the department's first approver, via HR's ownget_employee_leave_approver. If nothing resolves while the setting is on, show a readable message instead of the raw upstream error.Side effect (wanted): the approver now gets the notification and doc share that were being skipped.