2015-08-19 07:30:03 +00:00
|
|
|
## temp utility
|
2021-09-02 11:14:59 +00:00
|
|
|
|
2022-12-08 11:10:13 +00:00
|
|
|
from contextlib import contextmanager
|
|
|
|
|
2015-08-19 07:30:03 +00:00
|
|
|
import frappe
|
2022-12-08 11:10:13 +00:00
|
|
|
from frappe import _
|
2017-05-16 03:00:27 +00:00
|
|
|
from frappe.utils import cstr
|
2015-08-19 07:30:03 +00:00
|
|
|
|
2021-09-02 11:14:59 +00:00
|
|
|
from erpnext.utilities.activation import get_level
|
|
|
|
|
|
|
|
|
2015-08-19 07:30:03 +00:00
|
|
|
def update_doctypes():
|
2022-03-28 13:22:46 +00:00
|
|
|
for d in frappe.db.sql(
|
|
|
|
"""select df.parent, df.fieldname
|
2015-08-19 07:30:03 +00:00
|
|
|
from tabDocField df, tabDocType dt where df.fieldname
|
2022-03-28 13:22:46 +00:00
|
|
|
like "%description%" and df.parent = dt.name and dt.istable = 1""",
|
|
|
|
as_dict=1,
|
|
|
|
):
|
2015-08-19 07:30:03 +00:00
|
|
|
dt = frappe.get_doc("DocType", d.parent)
|
|
|
|
|
|
|
|
for f in dt.fields:
|
|
|
|
if f.fieldname == d.fieldname and f.fieldtype in ("Text", "Small Text"):
|
|
|
|
f.fieldtype = "Text Editor"
|
|
|
|
dt.save()
|
|
|
|
break
|
2016-06-25 14:21:48 +00:00
|
|
|
|
2022-03-28 13:22:46 +00:00
|
|
|
|
2016-06-25 14:21:48 +00:00
|
|
|
def get_site_info(site_info):
|
|
|
|
# called via hook
|
2022-03-28 13:22:46 +00:00
|
|
|
company = frappe.db.get_single_value("Global Defaults", "default_company")
|
2016-06-25 14:21:48 +00:00
|
|
|
domain = None
|
|
|
|
|
|
|
|
if not company:
|
2022-03-28 13:22:46 +00:00
|
|
|
company = frappe.db.sql("select name from `tabCompany` order by creation asc")
|
2016-06-25 14:21:48 +00:00
|
|
|
company = company[0][0] if company else None
|
|
|
|
|
|
|
|
if company:
|
2022-03-28 13:22:46 +00:00
|
|
|
domain = frappe.get_cached_value("Company", cstr(company), "domain")
|
2016-06-25 14:21:48 +00:00
|
|
|
|
2022-03-28 13:22:46 +00:00
|
|
|
return {"company": company, "domain": domain, "activation": get_level()}
|
2022-12-08 11:10:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
@contextmanager
|
|
|
|
def payment_app_import_guard():
|
|
|
|
marketplace_link = '<a href="https://frappecloud.com/marketplace/apps/payments">Marketplace</a>'
|
|
|
|
github_link = '<a href="https://github.com/frappe/payments/">GitHub</a>'
|
|
|
|
msg = _("payments app is not installed. Please install it from {} or {}").format(
|
|
|
|
marketplace_link, github_link
|
|
|
|
)
|
|
|
|
try:
|
|
|
|
yield
|
|
|
|
except ImportError:
|
|
|
|
frappe.throw(msg, title=_("Missing Payments App"))
|