From 249bc6167f2f395df6522914b699b81483517376 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Tue, 27 Dec 2016 18:15:36 +0530 Subject: [PATCH] fix company issue --- erpnext/setup/doctype/company/company.py | 2 +- erpnext/setup/doctype/company/test_company.py | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py index 94a01010fbb..32ad8ebe1b6 100644 --- a/erpnext/setup/doctype/company/company.py +++ b/erpnext/setup/doctype/company/company.py @@ -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, diff --git a/erpnext/setup/doctype/company/test_company.py b/erpnext/setup/doctype/company/test_company.py index 43cb4d3c421..d2e7d23d928 100644 --- a/erpnext/setup/doctype/company/test_company.py +++ b/erpnext/setup/doctype/company/test_company.py @@ -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) \ No newline at end of file + 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))