Skip to content

Instantly share code, notes, and snippets.

@rmehta
Created January 23, 2013 11:35
Show Gist options
  • Save rmehta/4604615 to your computer and use it in GitHub Desktop.
Save rmehta/4604615 to your computer and use it in GitHub Desktop.
import webnotes
def do():
webnotes.connect()
for dt in webnotes.conn.sql("""select distinct parent from tabDocField
where fieldtype="Currency" """):
doctype = webnotes.model_wrapper("DocType", dt[0])
changed = False
for d in doctype.doclist.get({"doctype":"DocField", "fieldtype":"Currency"}):
if not d.options:
has_company = ""
if doctype.doclist.get({"doctype":"DocField", "fieldname":"company",
"options":["in", ["Company", "link:Company"]]}):
has_company = " (company)"
option = raw_input(d.parent + " " + d.fieldname + has_company + ":")
if option=="1":
d.options = "eval:erpnext.get_currency(doc.company)"
changed = True
if option=="2":
d.options = "currency"
changed = True
if option=="3":
d.fieldtype = "Float"
changed = True
if option=="q":
return
if changed:
doctype.save()
if __name__=="__main__":
do()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment