NOTE : This is done on version-14
1 - take backup of existing site
2 - change setup_complete
key’s value to 0
in System Settings using bench console
frappe.db.set_value("System Settings", "System Settings", "setup_complete", 0)
frappe.db.commit()
3 - install erpnext
and run bench migrate
4 - run after_install()
function on path erpnext.setup.install
5 - set default values using below script
import frappe, logging
@frappe.whitelist()
def setup_erpnext_defaults():
company_name = "Bright Eduway"
country = "Qatar"
currency = "QAR"
fy_start_date = "2025-04-01"
fy_end_date = "2026-03-31"
chart_template = "Standard"
try:
# Create Fiscal Year
if not frappe.db.exists("Fiscal Year", "2025-2026"):
fy = frappe.get_doc({
"doctype": "Fiscal Year",
"year": "2025-2026",
"year_start_date": fy_start_date,
"year_end_date": fy_end_date
})
fy.insert()
# Create Company
if not frappe.db.exists("Company", company_name):
company = frappe.get_doc({
"doctype": "Company",
"company_name": company_name,
"default_currency": currency,
"country": country,
"chart_of_accounts": chart_template
})
company.insert()
# Set Global Defaults
frappe.db.set_value("Global Defaults", None, "default_company", company_name)
frappe.db.set_value("Global Defaults", None, "default_currency", currency)
frappe.db.set_value("Global Defaults", None, "country", country)
frappe.db.set_value("Global Defaults", None, "current_fiscal_year", "2025-2026")
# Set Accounts Settings
frappe.db.set_value("Accounts Settings", None, "fiscal_year", "2025-2026")
frappe.db.commit()
print("ERPNext defaults have been successfully configured.")
except Exception as err:
logging.error("SCRIPT_ERROR(SEDM) : "+str(err))
frappe.db.rollback()