jey_erp/jey_erp/custom/rename_default_groups.py

42 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import frappe
ITEM_GROUP_RENAMES = {
"Products": "Məhsullar",
"Raw Material": "Xammal",
"Services": "Xidmətlər",
"Sub Assemblies": "Alt məclislər",
"Consumable": "İstehlak materialı",
}
SUPPLIER_GROUP_RENAMES = {
"Local": "Yerli",
"Electrical": "Elektrik",
"Hardware": "Avadanlıq",
"Pharmaceutical": "Əczaçılıq",
"Distributor": "Distribyutor",
}
def rename_default_groups(args=None):
for old_name, new_name in ITEM_GROUP_RENAMES.items():
_rename_doc("Item Group", old_name, new_name)
for old_name, new_name in SUPPLIER_GROUP_RENAMES.items():
_rename_doc("Supplier Group", old_name, new_name)
def _rename_doc(doctype, old_name, new_name):
if frappe.db.exists(doctype, new_name):
return
if not frappe.db.exists(doctype, old_name):
return
try:
frappe.rename_doc(doctype, old_name, new_name, force=True)
frappe.db.commit()
print(f"[jey_erp] Renamed {doctype}: {old_name} -> {new_name}")
except Exception as e:
print(f"[jey_erp] Error renaming {doctype} '{old_name}': {e}")