[Fix] Budget against Projects
- Test case fixed
- Either cost center or project is mandatory
diff --git a/erpnext/accounts/doctype/budget/budget.json b/erpnext/accounts/doctype/budget/budget.json
index d177fa8..1dad38f 100644
--- a/erpnext/accounts/doctype/budget/budget.json
+++ b/erpnext/accounts/doctype/budget/budget.json
@@ -34,7 +34,7 @@
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
- "reqd": 1,
+ "reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
@@ -370,7 +370,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2016-11-22 11:58:42.211690",
+ "modified": "2016-11-23 11:20:46.600912",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Budget",
diff --git a/erpnext/accounts/doctype/budget/budget.py b/erpnext/accounts/doctype/budget/budget.py
index 7df7151..a3cc110 100644
--- a/erpnext/accounts/doctype/budget/budget.py
+++ b/erpnext/accounts/doctype/budget/budget.py
@@ -20,6 +20,8 @@
self.name = make_autoname(self.project + "/" + self.fiscal_year + "/.###")
def validate(self):
+ if not self.cost_center and not self.project:
+ frappe.throw(_("Budget should be allocated against either Cost Center or Project."))
if self.cost_center:
self.validate_duplicate("cost_center")
if self.project:
diff --git a/erpnext/accounts/doctype/budget/test_budget.py b/erpnext/accounts/doctype/budget/test_budget.py
index ef6a1c8..ee44ee0 100644
--- a/erpnext/accounts/doctype/budget/test_budget.py
+++ b/erpnext/accounts/doctype/budget/test_budget.py
@@ -5,7 +5,7 @@
import frappe
import unittest
-from erpnext.accounts.doctype.budget.budget import get_actual_expense, BudgetError
+from erpnext.accounts.doctype.budget.budget import get_actual_expense_for_CC, BudgetError
from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry
class TestBudget(unittest.TestCase):
@@ -89,7 +89,7 @@
budget.cancel()
def set_total_expense_zero(posting_date, cost_center=None):
- existing_expense = get_actual_expense({
+ existing_expense = get_actual_expense_for_CC({
"account": "_Test Account Cost for Goods Sold - _TC",
"cost_center": cost_center or "_Test Cost Center - _TC",
"monthly_end_date": posting_date,