Minor fixes

This commit is contained in:
Nabin Hait 2016-01-15 11:09:25 +05:30
parent 1bf440b03a
commit ad42d2f67a
2 changed files with 16 additions and 0 deletions

View File

@ -27,6 +27,7 @@ class Account(Document):
return return
self.validate_parent() self.validate_parent()
self.validate_root_details() self.validate_root_details()
self.validate_group_or_ledger()
self.set_root_and_report_type() self.set_root_and_report_type()
self.validate_mandatory() self.validate_mandatory()
self.validate_warehouse_account() self.validate_warehouse_account()
@ -81,6 +82,20 @@ class Account(Document):
if not self.parent_account and not self.is_group: if not self.parent_account and not self.is_group:
frappe.throw(_("Root Account must be a 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): def validate_frozen_accounts_modifier(self):
old_value = frappe.db.get_value("Account", self.name, "freeze_account") old_value = frappe.db.get_value("Account", self.name, "freeze_account")
if old_value and old_value != self.freeze_account: if old_value and old_value != self.freeze_account:

View File

@ -233,6 +233,7 @@ class StockEntry(StockController):
self.posting_date, self.posting_time, d.actual_qty, d.transfer_qty), NegativeStockError) self.posting_date, self.posting_time, d.actual_qty, d.transfer_qty), NegativeStockError)
def get_stock_and_rate(self): def get_stock_and_rate(self):
self.set_transfer_qty()
self.set_actual_qty() self.set_actual_qty()
self.calculate_rate_and_amount() self.calculate_rate_and_amount()