[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

@@ -348,4 +348,28 @@ def get_actual_expense(args):
from `tabGL Entry`
where account='%(account)s' and cost_center='%(cost_center)s'
and fiscal_year='%(fiscal_year)s' and company='%(company)s' %(condition)s
""" % (args))[0][0]
""" % (args))[0][0]
def rename_account_for(dt, olddn, newdn, merge):
old_account = get_account_for(dt, 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 = get_account_for(dt, 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)
def get_account_for(account_for_doctype, account_for):
if account_for_doctype in ["Customer", "Supplier"]:
account_for_field = "master_type"
elif account_for_doctype == "Warehouse":
account_for_field = "account_type"
return webnotes.conn.get_value("Account", {account_for_field: account_for_doctype,
"master_name": account_for})