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(): |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 10 | for d in frappe.db.sql( |
| 11 | """select df.parent, df.fieldname |
Rushabh Mehta | 81e9d4e | 2015-08-19 13:00:03 +0530 | [diff] [blame] | 12 | from tabDocField df, tabDocType dt where df.fieldname |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 13 | like "%description%" and df.parent = dt.name and dt.istable = 1""", |
| 14 | as_dict=1, |
| 15 | ): |
Rushabh Mehta | 81e9d4e | 2015-08-19 13:00:03 +0530 | [diff] [blame] | 16 | dt = frappe.get_doc("DocType", d.parent) |
| 17 | |
| 18 | for f in dt.fields: |
| 19 | if f.fieldname == d.fieldname and f.fieldtype in ("Text", "Small Text"): |
Rushabh Mehta | 81e9d4e | 2015-08-19 13:00:03 +0530 | [diff] [blame] | 20 | f.fieldtype = "Text Editor" |
| 21 | dt.save() |
| 22 | break |
Anand Doshi | f576f3b | 2016-06-25 19:51:48 +0530 | [diff] [blame] | 23 | |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 24 | |
Anand Doshi | f576f3b | 2016-06-25 19:51:48 +0530 | [diff] [blame] | 25 | def get_site_info(site_info): |
| 26 | # called via hook |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 27 | company = frappe.db.get_single_value("Global Defaults", "default_company") |
Anand Doshi | f576f3b | 2016-06-25 19:51:48 +0530 | [diff] [blame] | 28 | domain = None |
| 29 | |
| 30 | if not company: |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 31 | company = frappe.db.sql("select name from `tabCompany` order by creation asc") |
Anand Doshi | f576f3b | 2016-06-25 19:51:48 +0530 | [diff] [blame] | 32 | company = company[0][0] if company else None |
| 33 | |
| 34 | if company: |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 35 | domain = frappe.get_cached_value("Company", cstr(company), "domain") |
Anand Doshi | f576f3b | 2016-06-25 19:51:48 +0530 | [diff] [blame] | 36 | |
Ankush Menat | 494bd9e | 2022-03-28 18:52:46 +0530 | [diff] [blame] | 37 | return {"company": company, "domain": domain, "activation": get_level()} |