From 79ffc2b3a79ceb3d74eee27289ba211598374abf Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 25 Feb 2015 18:32:08 +0530 Subject: [PATCH 1/3] fix in financial statements --- erpnext/accounts/report/financial_statements.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py index 9978bb44d4..4ae61ca513 100644 --- a/erpnext/accounts/report/financial_statements.py +++ b/erpnext/accounts/report/financial_statements.py @@ -161,7 +161,8 @@ def add_total_row(out, balance_must_be, period_list): def get_accounts(company, root_type): # root lft, rgt root_account = frappe.db.sql("""select lft, rgt from `tabAccount` - where company=%s and root_type=%s order by lft limit 1""", + where company=%s and root_type=%s and ifnull(parent_account, '') = '' + order by lft limit 1""", (company, root_type), as_dict=True) if not root_account: From 98a8fae7c218811d3d21861bb7417d9714ff1ca0 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 26 Feb 2015 11:37:07 +0530 Subject: [PATCH 2/3] hotfix for fetching default account and warehouse --- erpnext/stock/get_item_details.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index 7633bc91fc..6f9839d456 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -171,7 +171,8 @@ def get_basic_details(args, item_doc): # if default specified in item is for another company, fetch from company for d in [["Account", "income_account", "default_income_account"], ["Account", "expense_account", "default_expense_account"], ["Cost Center", "cost_center", "cost_center"], ["Warehouse", "warehouse", ""]]: - if not out[d[1]] or args.company != frappe.db.get_value(d[0], out.get(d[1]), "company"): + company = frappe.db.get_value(d[0], out.get(d[1]), "company") + if not out[d[1]] or (company and args.company != company): out[d[1]] = frappe.db.get_value("Company", args.company, d[2]) if d[2] else None for fieldname in ("item_name", "item_group", "barcode", "brand", "stock_uom"): From 836f9f34e42a41d0a64792ca8c6b49eb2c35320e Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 26 Feb 2015 11:40:20 +0530 Subject: [PATCH 3/3] warehouse mandatory in sales invoice if update_stock --- erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index a2bf78c449..676a468aa9 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -59,6 +59,7 @@ class SalesInvoice(SellingController): if cint(self.update_stock): self.validate_item_code() + self.validate_warehouse() self.update_current_stock() self.validate_delivery_note() @@ -350,6 +351,11 @@ class SalesInvoice(SellingController): if not d.item_code: msgprint(_("Item Code required at Row No {0}").format(d.idx), raise_exception=True) + def validate_warehouse(self): + for d in self.get('entries'): + if not d.warehouse: + frappe.throw(_("Warehouse required at Row No {0}").format(d.idx)) + def validate_delivery_note(self): for d in self.get("entries"): if d.delivery_note: