didi-website-erp-crm/erp_crm/scripts/archive/fix-sidebar.py

67 lines
2.7 KiB
Python

import frappe
def execute():
# Hide ALL public workspaces
for ws in frappe.get_all("Workspace", filters={"public": 1}, fields=["name"]):
doc = frappe.get_doc("Workspace", ws.name)
doc.public = 0
doc.save(ignore_permissions=True)
# Delete old DiDi workspaces
for ws in frappe.get_all("Workspace", filters={"name": ["like", "%DiDi%"]}, fields=["name"]):
frappe.delete_doc("Workspace", ws.name, force=True)
# Create sidebar workspaces - each one is a clean page
create_workspace("Facturi", "invoice", 1, "Sales Invoice", [
{"type": "DocType", "link_to": "Sales Invoice", "label": "Lista Facturi"},
])
create_workspace("Clienti", "user", 2, "Customer", [
{"type": "DocType", "link_to": "Customer", "label": "Lista Clienti"},
])
create_workspace("CRM", "lead", 3, "Lead", [
{"type": "DocType", "link_to": "Lead", "label": "Lead-uri"},
{"type": "DocType", "link_to": "Sales Stage", "label": "Etape Pipeline"},
{"type": "DocType", "link_to": "Lead Source", "label": "Surse Lead"},
])
create_workspace("Servicii", "box", 4, "Item", [
{"type": "DocType", "link_to": "Item", "label": "Produse / Servicii"},
{"type": "DocType", "link_to": "Subscription Plan", "label": "Planuri Abonament"},
])
create_workspace("Plati", "credit-card", 5, "Payment Log", [
{"type": "DocType", "link_to": "Payment Log", "label": "Log Plati Stripe"},
{"type": "DocType", "link_to": "Service Agreement", "label": "Acorduri Servicii"},
])
create_workspace("Contabilitate", "calculator", 6, "Account", [
{"type": "DocType", "link_to": "Account", "label": "Plan de Conturi"},
{"type": "DocType", "link_to": "Sales Taxes and Charges Template", "label": "Template TVA"},
{"type": "DocType", "link_to": "Supplier", "label": "Furnizori"},
{"type": "DocType", "link_to": "Purchase Invoice", "label": "Facturi Furnizori"},
])
create_workspace("Website CMS", "globe", 7, "Website Content", [
{"type": "DocType", "link_to": "Website Content", "label": "Continut Pagini"},
{"type": "DocType", "link_to": "Email Template", "label": "Template-uri Email"},
])
frappe.db.commit()
print("\n=== Sidebar creat: Facturi, Clienti, CRM, Servicii, Plati, Contabilitate, Website CMS ===")
def create_workspace(label, icon, seq, module_doctype, shortcuts):
ws = frappe.get_doc({
"doctype": "Workspace",
"label": label,
"title": label,
"module": "Didi Custom",
"icon": icon,
"public": 1,
"sequence_id": seq,
"shortcuts": shortcuts,
})
ws.insert(ignore_permissions=True)
print(f" Created: {label}")