fix company issue

This commit is contained in:
Rohit Waghchaure 2016-12-27 18:15:36 +05:30
parent aa9b8603b9
commit 249bc6167f
2 changed files with 10 additions and 4 deletions

View File

@ -166,7 +166,7 @@ class Company(Document):
def mode_of_payment(self):
cash = frappe.db.get_value('Mode of Payment', {'type': 'Cash'}, 'name')
if cash:
if cash and not frappe.db.get_value('Mode of Payment Account', {'company': self.name}):
mode_of_payment = frappe.get_doc('Mode of Payment', cash)
mode_of_payment.append('accounts', {
'company': self.name,

View File

@ -40,9 +40,10 @@ class TestCompany(unittest.TestCase):
acc = frappe.get_doc("Account", account)
for prop, val in acc_property.items():
self.assertEqual(acc.get(prop), val)
self.delete_mode_of_payment("COA from Existing Company")
frappe.delete_doc("Company", "COA from Existing Company")
def test_coa_based_on_country_template(self):
countries = ["India", "Brazil", "United Arab Emirates", "Canada", "Germany", "France",
"Guatemala", "Indonesia", "Mexico", "Nicaragua", "Netherlands", "Singapore"]
@ -78,4 +79,9 @@ class TestCompany(unittest.TestCase):
self.assertTrue(frappe.get_all("Account", filters))
finally:
frappe.delete_doc("Company", template)
self.delete_mode_of_payment(template)
frappe.delete_doc("Company", template)
def delete_mode_of_payment(self, company):
frappe.db.sql(""" delete from `tabMode of Payment Account`
where company =%s """, (company))