import frappe frappe.init(site="erpnext.local") frappe.connect() try: # Get Westech workspace ws = frappe.get_doc("Workspace", "Westech") # Create HTML block with template links html_block = '''

📋 Print Format Templates

🟣 Purple Sheet
Special Handling Log
🟢 Green Sheet
R2 Special Handling Log
🏷️ Pallet Label
4x6" with Service Level
📦 R2 UW Label
Controlled Stream
''' # Parse existing content import json content = json.loads(ws.content) if ws.content else [] # Check if template links section already exists existing_idx = None for i, block in enumerate(content): if block.get('type') == 'custom_block' and 'Print Format Templates' in block.get('data', {}).get('html', ''): existing_idx = i break if existing_idx is not None: # Update existing block content[existing_idx]['data']['html'] = html_block print(f"✓ Updated existing template links block") else: # Add new block after header template_block = { "type": "custom_block", "data": { "html": html_block } } # Insert after first header block insert_idx = 1 for i, block in enumerate(content): if block.get('type') == 'header': insert_idx = i + 1 break content.insert(insert_idx, template_block) print(f"✓ Added new template links block") # Update workspace ws.content = json.dumps(content) # Remove broken shortcuts before saving if hasattr(ws, 'shortcuts'): ws.shortcuts = [s for s in ws.shortcuts if frappe.db.exists(s.doctype, s.link_to)] ws.save(ignore_permissions=True) frappe.db.commit() print(f"✓ Workspace 'Westech' updated successfully") print(f"✓ View at: https://erp.diagalon.com/app/westech") finally: frappe.destroy()