You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

54 rivejä
1.4 KiB

  1. ## temp utility
  2. from contextlib import contextmanager
  3. import frappe
  4. from frappe import _
  5. from frappe.utils import cstr
  6. from erpnext.utilities.activation import get_level
  7. def update_doctypes():
  8. for d in frappe.db.sql(
  9. """select df.parent, df.fieldname
  10. from tabDocField df, tabDocType dt where df.fieldname
  11. like "%description%" and df.parent = dt.name and dt.istable = 1""",
  12. as_dict=1,
  13. ):
  14. dt = frappe.get_doc("DocType", d.parent)
  15. for f in dt.fields:
  16. if f.fieldname == d.fieldname and f.fieldtype in ("Text", "Small Text"):
  17. f.fieldtype = "Text Editor"
  18. dt.save()
  19. break
  20. def get_site_info(site_info):
  21. # called via hook
  22. company = frappe.db.get_single_value("Global Defaults", "default_company")
  23. domain = None
  24. if not company:
  25. company = frappe.db.sql("select name from `tabCompany` order by creation asc")
  26. company = company[0][0] if company else None
  27. if company:
  28. domain = frappe.get_cached_value("Company", cstr(company), "domain")
  29. return {"company": company, "domain": domain, "activation": get_level()}
  30. @contextmanager
  31. def payment_app_import_guard():
  32. marketplace_link = '<a href="https://frappecloud.com/marketplace/apps/payments">Marketplace</a>'
  33. github_link = '<a href="https://github.com/frappe/payments/">GitHub</a>'
  34. msg = _("payments app is not installed. Please install it from {} or {}").format(
  35. marketplace_link, github_link
  36. )
  37. try:
  38. yield
  39. except ImportError:
  40. frappe.throw(msg, title=_("Missing Payments App"))