brotherton-erpnext/erpnext/utilities/__init__.py
Aditya Hase 6ccb6562f1 Python 3 compatibility syntax error fixes (#10519)
* Use Python 3 style print function

* Use 'Exception as e' instead of 'Exception, e'

* Unpack tuple arguments explicitly in instead of relying on auto unpacking

* Use consistent indentation

* Use 0 if stock_frozen_upto_days is None
2017-08-28 18:17:36 +05:30

37 lines
1.0 KiB
Python

## temp utility
from __future__ import print_function
import frappe
from erpnext.utilities.activation import get_level
from frappe.utils import cstr
def update_doctypes():
for d in frappe.db.sql("""select df.parent, df.fieldname
from tabDocField df, tabDocType dt where df.fieldname
like "%description%" and df.parent = dt.name and dt.istable = 1""", as_dict=1):
dt = frappe.get_doc("DocType", d.parent)
for f in dt.fields:
if f.fieldname == d.fieldname and f.fieldtype in ("Text", "Small Text"):
print(f.parent, f.fieldname)
f.fieldtype = "Text Editor"
dt.save()
break
def get_site_info(site_info):
# called via hook
company = frappe.db.get_single_value('Global Defaults', 'default_company')
domain = None
if not company:
company = frappe.db.sql('select name from `tabCompany` order by creation asc')
company = company[0][0] if company else None
if company:
domain = frappe.db.get_value('Company', cstr(company), 'domain')
return {
'company': company,
'domain': domain,
'activation': get_level()
}