Unlocking ERPNext’s Full Potential: A Step-by-Step Guide to Adding Custom Changes Locally and Pushing to FrappeCloud
Image by Breezy - hkhazo.biz.id

Unlocking ERPNext’s Full Potential: A Step-by-Step Guide to Adding Custom Changes Locally and Pushing to FrappeCloud

Posted on

Are you tired of feeling limited by ERPNext’s out-of-the-box features? Do you need to make custom changes to tailor the system to your organization’s unique needs? Look no further! In this comprehensive guide, we’ll walk you through the process of adding custom changes to ERPNext locally and pushing them to FrappeCloud.

Why Make Custom Changes?

ERPNext is an incredibly powerful and flexible system, but it’s not perfect. Sometimes, you need to make changes to accommodate specific business processes, integrate with external systems, or simply to make life easier for your users. Custom changes can help you:

  • Improve system performance and efficiency
  • Enhance user experience and adoption
  • Integrate with external systems and services
  • Automate manual processes and reduce errors
  • Gain a competitive edge in your industry

Preparing Your Local Environment

Before you start making custom changes, you’ll need to set up your local ERPNext environment. If you haven’t already, install ERPNext on your local machine using the following command:

bench init erpnext && cd erpnext && bench start

This will create a new ERPNext instance on your local machine, complete with a development bench.

Identifying the Change You Want to Make

Take a moment to identify the specific change you want to make. What problem are you trying to solve? What feature do you want to add or modify? Write down your requirements and break them down into smaller, manageable tasks.

For the purposes of this guide, let’s say you want to add a custom field to the Customer doctype. You’ve identified the requirement as:

“Add a new field called ‘Customer Source’ to the Customer doctype, with options for ‘Social Media’, ‘Referral’, and ‘Online Search’.”

Creating a New Frappe App

To make custom changes, you’ll need to create a new Frappe app. This app will contain your custom code and will be used to push changes to FrappeCloud. To create a new app, navigate to your ERPNext directory and run:

bench new-app my-custom-app

This will create a new directory called `my-custom-app` with the basic structure for a Frappe app.

Adding Custom Code

Now it’s time to add your custom code. In this example, you’ll add a new field to the Customer doctype. Create a new file called `custom_fields.py` in your `my-custom-app` directory:

touch my-custom-app/custom_fields.py

In this file, add the following code:


from frappe.custom.doctype.custom_field.custom_field import create_custom_fields

def create_custom_fields_for_customer():
    fields = [
        {
            'fieldname': 'customer_source',
            'label': 'Customer Source',
            'fieldtype': 'Select',
            'options': 'Social Media\nReferral\nOnline Search'
        }
    ]

    create_custom_fields({
        'Customer': fields
    })

This code defines a new custom field called `customer_source` for the Customer doctype.

Building and Reloading

After adding your custom code, you’ll need to build and reload your app. Run the following commands:

bench build-my-custom-app
bench reload-doctype Customer

The first command builds your app, while the second command reloads the Customer doctype to reflect your changes.

Testing Your Custom Change

Log in to your local ERPNext instance and navigate to the Customer doctype. You should see your new custom field, ‘Customer Source’, with the options you specified:

Field Name Label Field Type Options
customer_source Customer Source Select Social Media, Referral, Online Search

Test your custom field by creating a new Customer document and selecting an option from the ‘Customer Source’ dropdown.

Pushing Changes to FrappeCloud

Now that you’ve tested your custom change locally, it’s time to push it to FrappeCloud. To do this, you’ll need to create a new version of your app:

bench release my-custom-app 0.1.0

This creates a new version of your app, which you can then push to FrappeCloud:

bench deploy my-custom-app --variant production

This command deploys your app to FrappeCloud, making your custom change available to all users.

Conclusion

In this guide, you’ve learned how to make custom changes to ERPNext locally and push them to FrappeCloud. By following these steps, you can unlock the full potential of ERPNext and tailor it to your organization’s unique needs. Remember to always test your custom changes locally before pushing them to production, and don’t be afraid to experiment and try new things!

Happy customizing!

Note: This article is for informational purposes only and is not intended to be a substitute for official ERPNext documentation or support. Always follow best practices and consult with ERPNext experts before making custom changes to your system.

Frequently Asked Question

Got stuck with customizing ERPNext locally and pulling it to FrappeCloud? We’ve got you covered!

Q: What’s the best way to make a custom change in ERPNext locally?

A: Ah, easy peasy! To make a custom change in ERPNext locally, create a new branch in your repository, make the changes, and commit them. Make sure to test your changes thoroughly before pushing them to FrappeCloud.

Q: How do I pull my custom change to FrappeCloud?

A: Simple! Once you’ve made your custom change and committed it, push the changes to your GitHub repository. Then, go to your FrappeCloud account, navigate to the “Setup” page, and click on “Update Now” to pull the changes.

Q: What if I mess up my custom change and want to revert?

A: Don’t panic! If you mess up your custom change, just create a new branch from the previous commit before you made the changes, and revert to that branch. Then, push the changes to your GitHub repository and update FrappeCloud.

Q: Can I make custom changes to ERPNext core files?

A: Ah, not so fast! We strongly advise against making custom changes to ERPNext core files, as it can lead to compatibility issues and make future updates a nightmare. Instead, create custom apps or use hooks to extend ERPNext’s functionality.

Q: How do I ensure my custom change is compatible with future ERPNext updates?

A: Wise question! To ensure compatibility, make sure to test your custom change with the latest ERPNext version, and use hooks and APIs to extend functionality. Also, keep an eye on the ERPNext changelog and roadmap to stay ahead of changes that might affect your custom code.

Leave a Reply

Your email address will not be published. Required fields are marked *