Skip to content

Instantly share code, notes, and snippets.

@rmehta
Created July 4, 2013 09:56
Show Gist options
  • Save rmehta/5926427 to your computer and use it in GitHub Desktop.
Save rmehta/5926427 to your computer and use it in GitHub Desktop.
import webnotes, json
webnotes.connect()
source = "Quotation"
target = "Sales Order"
doclist = webnotes.bean("DocType Mapper", "Quotation-Sales Order").doclist
map_id = {}
table_map = {}
for d in doclist.get({"doctype": "Table Mapper Detail"}):
map_id[d.match_id] = {"from": d.from_table, "to": d.to_table}
table_map[d.from_table] = {
"doctype": d.to_table,
"field_map": {}
}
for d in doclist.get({"doctype": "Field Mapper Detail"}):
table_map[map_id[d.match_id]["from"]]["field_map"][d.from_field] = d.to_field
print json.dumps(table_map, indent=4, sort_keys=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment