[fix] [minor] rename and merge for customer and supplier

This commit is contained in:
Nabin Hait
2013-11-26 15:03:51 +05:30
parent d3e7a6d57a
commit 131939a742
4 changed files with 42 additions and 49 deletions

View File

@@ -73,7 +73,8 @@ class DocType:
if warehouse_account:
webnotes.delete_doc("Account", warehouse_account)
if sql("""select name from `tabStock Ledger Entry` where warehouse = %s""", self.doc.name):
if webnotes.conn.sql("""select name from `tabStock Ledger Entry`
where warehouse = %s""", self.doc.name):
msgprint("""Warehouse can not be deleted as stock ledger entry
exists for this warehouse.""", raise_exception=1)
@@ -88,7 +89,8 @@ class DocType:
webnotes.conn.sql("delete from `tabBin` where warehouse=%s", olddn)
self.rename_account(olddn, new_warehouse, merge)
from accounts.utils import rename_account_for
rename_account_for("Warehouse", olddn, new_warehouse, merge)
return new_warehouse
@@ -109,21 +111,4 @@ class DocType:
webnotes.conn.set_default("allow_negative_stock",
webnotes.conn.get_value("Stock Settings", None, "allow_negative_stock"))
webnotes.conn.auto_commit_on_many_writes = 0
def rename_account(self, olddn, newdn, merge):
old_account = webnotes.conn.get_value("Account",
{"account_type": "Warehouse", "master_name": olddn})
if old_account:
new_account = None
if not merge:
if old_account == olddn:
new_account = webnotes.rename_doc("Account", olddn, newdn)
else:
existing_new_account = webnotes.conn.get_value("Account",
{"account_type": "Warehouse", "master_name": newdn})
new_account = webnotes.rename_doc("Account", old_account,
existing_new_account or newdn, merge=True if existing_new_account else False)
if new_account:
webnotes.conn.set_value("Account", new_account, "master_name", newdn)
webnotes.conn.auto_commit_on_many_writes = 0