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

42 lines
1.8 KiB
Python

import frappe
def execute():
# Delete old DiDi workspace
if frappe.db.exists("Workspace", "DiDi"):
frappe.delete_doc("Workspace", "DiDi", force=True)
# Hide ALL other 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)
print(f" Hidden: {ws.name}")
# Create clean DiDi workspace
ws = frappe.get_doc({
"doctype": "Workspace",
"name": "DiDi",
"label": "DiDi",
"title": "DiDi - Panou Principal",
"module": "Didi Custom",
"icon": "home",
"public": 1,
"sequence_id": 0,
"shortcuts": [
{"type": "DocType", "link_to": "Sales Invoice", "label": "FACTURI"},
{"type": "DocType", "link_to": "Customer", "label": "CLIENTI"},
{"type": "DocType", "link_to": "Lead", "label": "LEAD-URI CRM"},
{"type": "DocType", "link_to": "Payment Log", "label": "LOG PLATI STRIPE"},
{"type": "DocType", "link_to": "Service Agreement", "label": "ACORDURI SERVICII"},
{"type": "DocType", "link_to": "Item", "label": "SERVICII / PRODUSE"},
{"type": "DocType", "link_to": "Subscription Plan", "label": "PLANURI ABONAMENT"},
{"type": "DocType", "link_to": "Website Content", "label": "CONTINUT WEBSITE (CMS)"},
{"type": "DocType", "link_to": "Supplier", "label": "FURNIZORI"},
{"type": "DocType", "link_to": "Email Template", "label": "TEMPLATE-URI EMAIL"},
{"type": "DocType", "link_to": "Account", "label": "PLAN DE CONTURI"},
],
})
ws.insert(ignore_permissions=True)
print("DiDi workspace created with all shortcuts")
frappe.db.commit()