From Development to Production in ERPNext

Table of Contents

From Development to Production in ERPNext

🏰 The Royal Guide to Frappe/ERPNext Customization

A tale of kingdoms, customizations, and magical code implementations

🎯 The Golden Rule of the Realm

Never tamper with the ancient scrolls (standard doctypes) directly! 📜
Instead, we shall create our own magical kingdom and customize from there.


🏗️ Step 1: Establishing Your Kingdom

🌟 Create Your Custom Realm

bench new-app your_magical_kingdom

This creates your very own kingdom where all your customizations will live! 🏰


⚔️ Step 2: The Art of Customization (Not Direct Editing!)

🧙‍♀️ For Standard Doctypes (The Ancient Scrolls)

When you want to modify existing doctypes like Customer, Item, etc.:

  1. Navigate to the doctype you want to customize 📋
  2. Click “Customize” (don’t edit directly!) ✏️
  3. Make your magical changes
  4. Export your enchantments:
    • Find the “Action” button 🎬
    • Click “Export Customization” 📤
    • Select your custom kingdom as the module 🏰
    • Your customizations are now safely stored in:
      bench/apps/your_magical_kingdom/your_magical_kingdom/custom_module/custom/
      

🏰 For Child Tables Too!

Follow the same ritual for customizing child tables - always export to your kingdom! 👶


🎨 Step 3: Creating Your Own Magical Doctypes

🌟 New Doctype Creation

When creating brand new doctypes:

  1. Create New Doctype 📝
  2. IMPORTANT: When asked for module, select YOUR kingdom’s module 🏰
  3. Never select standard app modules! ⚠️

This creates your doctype’s dwelling in:

bench/apps/your_magical_kingdom/your_magical_kingdom/doctype/your_doctype/

💻 Step 4: The Code Chambers

🐍 Server-Side Spells (Python)

For your custom doctypes:

  • Edit the .py files in your doctype’s directory directly 📁

For standard doctypes:

  • Create a special code chamber: apps/your_kingdom/your_kingdom/custom_scripts/
  • Use hooks.py to connect your spells to the standard doctypes 🔗

⚡ Client-Side Magic (JavaScript)

Store all your frontend enchantments in:

apps/your_magical_kingdom/your_magical_kingdom/public/js/

Use hooks.py to bind these spells to your doctypes! 🎯


🚀 Step 5: Deploying Your Kingdom

🌍 Moving from Dev Castle to Production Fortress

  1. Initialize Git in your kingdom:

    cd apps/your_magical_kingdom
    git init
    git add .
    git commit -m "Initial kingdom setup"
    
  2. Push to GitHub:

    git remote add origin your-repo-url
    git push -u origin main
    
  3. Deploy to Production:

    # On production server
    bench get-app your-repo-url
    bench install-app your_magical_kingdom
    

🚨 The Great Database Warning!

⚠️ NEVER Do This Forbidden Ritual!

DO NOT restore dev database backup to production! 💀

Why this spells doom:

  • .sql files only contain data records 📊
  • They DO NOT contain your UI customizations 🎨
  • Restoring will overwrite production data 💥

✅ The Proper Way:

  • Your customizations live in your custom app code 🏰
  • Deploy via Git (code changes) 📝
  • Let production keep its own data 💾

🎉 Kingdom Summary

🏰 Action🎯 Method📍 Location
Customize StandardUse Customize → ExportCustom App
Create New DoctypeSelect Custom ModuleCustom App
Server Codehooks.py + custom scriptsCustom App
Client Codepublic/js/Custom App
DeployGit push/pullGitHub → Production

🧙‍♂️ Final Wisdom

Remember, brave developer:

  • One Kingdom for all your customizations 🏰
  • Export everything to your realm 📤
  • Git is your teleportation spell 🪄
  • Never mix dev and prod databases ⚔️

May your code be bug-free and your customizations eternal! ✨🎊

Tags :