Rushabh Mehta | 81e9d4e | 2015-08-19 13:00:03 +0530 | [diff] [blame] | 1 | ## temp utility |
Chillar Anand | 915b343 | 2021-09-02 16:44:59 +0530 | [diff] [blame] | 2 | |
Rushabh Mehta | 81e9d4e | 2015-08-19 13:00:03 +0530 | [diff] [blame] | 3 | import frappe |
Saurabh | f4ee682 | 2017-05-16 08:30:27 +0530 | [diff] [blame] | 4 | from frappe.utils import cstr |
Rushabh Mehta | 81e9d4e | 2015-08-19 13:00:03 +0530 | [diff] [blame] | 5 | |
Chillar Anand | 915b343 | 2021-09-02 16:44:59 +0530 | [diff] [blame] | 6 | from erpnext.utilities.activation import get_level |
| 7 | |
| 8 | |
Rushabh Mehta | 81e9d4e | 2015-08-19 13:00:03 +0530 | [diff] [blame] | 9 | def update_doctypes(): |
| 10 | for d in frappe.db.sql("""select df.parent, df.fieldname |
| 11 | from tabDocField df, tabDocType dt where df.fieldname |
| 12 | like "%description%" and df.parent = dt.name and dt.istable = 1""", as_dict=1): |
| 13 | dt = frappe.get_doc("DocType", d.parent) |
| 14 | |
| 15 | for f in dt.fields: |
| 16 | if f.fieldname == d.fieldname and f.fieldtype in ("Text", "Small Text"): |
Rushabh Mehta | 81e9d4e | 2015-08-19 13:00:03 +0530 | [diff] [blame] | 17 | f.fieldtype = "Text Editor" |
| 18 | dt.save() |
| 19 | break |
Anand Doshi | f576f3b | 2016-06-25 19:51:48 +0530 | [diff] [blame] | 20 | |
| 21 | def get_site_info(site_info): |
| 22 | # called via hook |
| 23 | company = frappe.db.get_single_value('Global Defaults', 'default_company') |
| 24 | domain = None |
| 25 | |
| 26 | if not company: |
| 27 | company = frappe.db.sql('select name from `tabCompany` order by creation asc') |
| 28 | company = company[0][0] if company else None |
| 29 | |
| 30 | if company: |
Rushabh Mehta | 708e47a | 2018-08-08 16:37:31 +0530 | [diff] [blame] | 31 | domain = frappe.get_cached_value('Company', cstr(company), 'domain') |
Anand Doshi | f576f3b | 2016-06-25 19:51:48 +0530 | [diff] [blame] | 32 | |
| 33 | return { |
| 34 | 'company': company, |
Rushabh Mehta | 6dd461f | 2017-02-16 14:51:48 +0530 | [diff] [blame] | 35 | 'domain': domain, |
| 36 | 'activation': get_level() |
Anand Doshi | f576f3b | 2016-06-25 19:51:48 +0530 | [diff] [blame] | 37 | } |