From ad42d2f67abfd2706e817cd071ae971c55d800ab Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 15 Jan 2016 11:09:25 +0530 Subject: [PATCH] Minor fixes --- erpnext/accounts/doctype/account/account.py | 15 +++++++++++++++ erpnext/stock/doctype/stock_entry/stock_entry.py | 1 + 2 files changed, 16 insertions(+) diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py index a8ebbeaada..1f9c74df10 100644 --- a/erpnext/accounts/doctype/account/account.py +++ b/erpnext/accounts/doctype/account/account.py @@ -27,6 +27,7 @@ class Account(Document): return self.validate_parent() self.validate_root_details() + self.validate_group_or_ledger() self.set_root_and_report_type() self.validate_mandatory() self.validate_warehouse_account() @@ -80,6 +81,20 @@ class Account(Document): if not self.parent_account and not self.is_group: frappe.throw(_("Root Account must be a group")) + + def validate_group_or_ledger(self): + if self.get("__islocal"): + return + + existing_is_group = frappe.db.get_value("Account", self.name, "is_group") + if self.is_group != existing_is_group: + if self.check_gle_exists(): + throw(_("Account with existing transaction cannot be converted to ledger")) + elif self.is_group: + if self.account_type: + throw(_("Cannot covert to Group because Account Type is selected.")) + elif self.check_if_child_exists(): + throw(_("Account with child nodes cannot be set as ledger")) def validate_frozen_accounts_modifier(self): old_value = frappe.db.get_value("Account", self.name, "freeze_account") diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 247ce787a6..28939cae4c 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -233,6 +233,7 @@ class StockEntry(StockController): self.posting_date, self.posting_time, d.actual_qty, d.transfer_qty), NegativeStockError) def get_stock_and_rate(self): + self.set_transfer_qty() self.set_actual_qty() self.calculate_rate_and_amount()