Skip to content

Commit

Permalink
fix: Budget test cases getting failed due to a mandatory field child_wbs
Browse files Browse the repository at this point in the history
  • Loading branch information
anandk-spyke-o1 committed Jan 15, 2025
1 parent f0b0792 commit 7cf0582
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion erpnext/accounts/doctype/budget/test_budget.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,8 @@ def make_budget(**args):
budget.action_if_annual_budget_exceeded = "Stop"
budget.action_if_accumulated_monthly_budget_exceeded = "Ignore"
budget.budget_against = budget_against
budget.append("accounts", {"account": "_Test Account Cost for Goods Sold - _TC", "budget_amount": 200000})
wbs_name = setup_test_wbs()
budget.append("accounts", {"account": "_Test Account Cost for Goods Sold - _TC", "budget_amount": 200000,"child_wbs":wbs_name})

if args.applicable_on_material_request:
budget.applicable_on_material_request = 1
Expand All @@ -451,3 +452,27 @@ def make_budget(**args):
budget.submit()

return budget

# Setup test project
def setup_test_project():
desired_company = "_Test Company"
# Check if a project with the same name exists for the desired company
existing_project = frappe.get_all("Project", filters={"project_name": "_Test Company Project", "company": desired_company})
if not existing_project:
# Create a new project for the desired company
project = frappe.new_doc("Project")
project.project_name = "_Test Company Project"
project.company = desired_company
project.status = "Open"
project.is_active = 'Yes'
project.is_wbs = 1
project.start_date = nowdate()
project.save().submit()
return project.name
else:
return existing_project

# Setup test WBS
def setup_test_wbs():
setup_test_project()
return frappe.get_last_doc("Work Breakdown Structure")

0 comments on commit 7cf0582

Please sign in to comment.