From 659bc1aca4075e1c0e7afa259be024e9dca21092 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 12 Jan 2016 11:57:25 +0530 Subject: [PATCH] [minor] fixes reported on support --- .../accounts/doctype/sales_invoice/sales_invoice.py | 3 +++ erpnext/setup/setup_wizard/setup_wizard.py | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index c8ff232b5e..a0ce980bcc 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -300,6 +300,9 @@ class SalesInvoice(SellingController): account = frappe.db.get_value("Account", self.debit_to, ["account_type", "report_type", "account_currency"], as_dict=True) + if not account: + frappe.throw(_("Debit To is required")) + if account.report_type != "Balance Sheet": frappe.throw(_("Debit To account must be a Balance Sheet account")) diff --git a/erpnext/setup/setup_wizard/setup_wizard.py b/erpnext/setup/setup_wizard/setup_wizard.py index 9892e71eae..9be2880eb0 100644 --- a/erpnext/setup/setup_wizard/setup_wizard.py +++ b/erpnext/setup/setup_wizard/setup_wizard.py @@ -109,20 +109,24 @@ def create_fiscal_year_and_company(args): create_bank_account(args) args["curr_fiscal_year"] = curr_fiscal_year - + def create_bank_account(args): if args.get("bank_account"): - bank_account_group = frappe.db.get_value("Account", + bank_account_group = frappe.db.get_value("Account", {"account_type": "Bank", "is_group": 1, "root_type": "Asset"}) if bank_account_group: - frappe.get_doc({ + bank_account = frappe.get_doc({ "doctype": "Account", 'account_name': args.get("bank_account"), 'parent_account': bank_account_group, 'is_group':0, 'company':args.get('company_name').strip(), "account_type": "Bank", - }).insert() + }) + try: + bank_account.insert() + except RootNotEditable: + frappe.throw(_("Bank account cannot be named as {0}").format(args.get("bank_account"))) def create_price_lists(args): for pl_type, pl_name in (("Selling", _("Standard Selling")), ("Buying", _("Standard Buying"))):