Skip to content

Commit

Permalink
fix: validate if company is set in department
Browse files Browse the repository at this point in the history
  • Loading branch information
rs-rethik committed Jan 10, 2025
1 parent a4e8952 commit 51a1bab
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions hrms/hr/doctype/expense_claim/expense_claim.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,13 @@ def set_status(self, update=False):
self.status = status

def validate_company_and_department(self):
if self.department and self.company != frappe.db.get_value("Department", self.department, "company"):
frappe.throw(
_("Department {0} does not belong to company: {1}").format(self.department, self.company),
exc=MismatchError,
)
if self.department:
company = frappe.db.get_value("Department", self.department, "company")
if company and self.company != company:
frappe.throw(
_("Department {0} does not belong to company: {1}").format(self.department, self.company),
exc=MismatchError,
)

def on_update(self):
share_doc_with_approver(self, self.expense_approver)
Expand Down

0 comments on commit 51a1bab

Please sign in to comment.