Rushabh Mehta | ad45e31 | 2013-11-20 12:59:58 +0530 | [diff] [blame] | 1 | # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors |
Rushabh Mehta | e67d1fb | 2013-08-05 14:59:54 +0530 | [diff] [blame] | 2 | # License: GNU General Public License v3. See license.txt |
| 3 | |
Rushabh Mehta | 6382a42 | 2013-01-23 10:09:28 +0530 | [diff] [blame] | 4 | import webnotes |
| 5 | |
| 6 | def execute(): |
| 7 | # get all currencies |
| 8 | webnotes.reload_doc("setup", "doctype", "currency") |
| 9 | clist = [webnotes.conn.get_default("currency")] |
| 10 | for f in webnotes.conn.sql("""select parent, fieldname from tabDocField |
| 11 | where options in ('Currency', 'link:Currency')""", as_dict=1): |
| 12 | if not webnotes.conn.get_value("DocType", f.parent, "issingle"): |
| 13 | clist += [c[0] for c in webnotes.conn.sql("""select distinct `%s` |
| 14 | from `tab%s`""" % (f.fieldname, f.parent))] |
| 15 | |
| 16 | clist = list(set(clist)) |
| 17 | for c in clist: |
| 18 | if c: |
| 19 | webnotes.conn.sql("""update tabCurrency set `enabled`=1 where name=%s""", c) |