[Fix] Budget against Projects

- Test case fixed
- Either cost center or project is mandatory
This commit is contained in:
Manas Solanki 2016-11-22 18:11:30 +05:30
parent 1fa1fd7482
commit 5bd4d8a932
3 changed files with 6 additions and 4 deletions

View File

@ -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",

View File

@ -20,6 +20,8 @@ class Budget(Document):
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:

View File

@ -5,7 +5,7 @@ from __future__ import unicode_literals
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 @@ class TestBudget(unittest.TestCase):
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,