In business operations and management, the integration of large Enterprise Resource Planning (ERP) systems has become paramount. As I covered in a previous article, Frappe and ERPNext stand out as powerful tools in this domain, offering comprehensive capabilities for businesses of all sizes.
Frappe Framework is also a full-stack web application framework built with Python and JavaScript.
Frappe serves as the foundational framework upon which ERPNext is built, providing a flexible platform for developing and customizing ERP solutions. With the modular architecture and extensive feature set it has, ERPNext streamlines many business processes, from finance and inventory control to human resources and customer relations.
This article is divided into two parts and the first part will introduce us to the world of Frappe and ERPNext, exploring how these technologies can be leveraged to enhance ERP capabilities and drive business solutions.
Overview of ERPNext Framework
ERPNext, an open-source enterprise resource planning (ERP) program is based on the Frappe framework, a web application platform built with Python and JavaScript. It provides an extensive suite of integrated applications to handle several business activities, such as accounting, customer relationship management (CRM), sales, buying, inventory, manufacturing, human resources, and projects. Businesses can extend and modify ERPNext’s functions to meet their unique requirements. Its modular design offers flexibility by creating custom fields, forms, processes, and powerful dashboard and reporting features. The system enables multi-language, multi-currency transactions to guarantee safe and effective operations and has robust user management tools with roles and permissions.
ERPNext’s architecture is based on the Model-View-Controller Service (MVCS) architecture, ensuring clear data administration segregation, user interface, and business logic segregation. This design principle enhances the system’s efficiency and effectiveness. ERPNext also offers REST APIs for seamless integration with external apps and manages databases using MariaDB. It provides a range of deployment solutions, both on-premises and cloud-based, to cater to various company needs. The framework’s ability to scale vertically and horizontally makes it suitable for companies of all sizes. With the support of a thriving open-source community, ERPNext is constantly updated and improved, ensuring a cutting-edge and dynamic ERP system.
Overview of Frappe Framework
The Frappe Framework is also an open-source web application development framework written in Python. It is the foundation for ERPNext, enabling the creation of custom business applications with minimal coding. Frappe is built on the Model-View-Controller (MVC) architecture, which ensures a clear separation between data models, user interfaces, and business logic. This design pattern facilitates organized and efficient code management, making developing, maintaining, and scaling applications easier.
Key features of the Frappe Framework include its robust web-based interface, which allows developers to build responsive applications accessible from any device with an internet connection. It offers a robust code-less development environment through its integrated visual form builder, report builder, and workflow engine. Frappe facilitates smooth interaction with other systems and services by supporting RESTful APIs. It also has extensive documentation, role-based access control, and built-in user authentication, making it a flexible and easy-to-use platform for developing various business solutions.
Relationship between Frappe and ERPNext
The relationship between Frappe and ERPNext is foundational and symbiotic, with Frappe serving as the underlying framework upon which ERPNext is built. Frappe is the engine that powers ERPNext, providing the infrastructure and tools to develop and manage comprehensive business applications. ERPNext, in turn, demonstrates the capabilities of the Frappe framework and drives its continuous improvement.
Here’s an overview of this relationship:
Foundation and Extensions: Frappe provides the foundational technology, while ERPNext serves as an extensive application suite that showcases the power and flexibility of the Frappe framework.
Development Synergy: Improvements and updates in the Frappe framework directly benefit ERPNext, enhancing its performance, security, and features. Conversely, ERPNext users’ demands, and feedback drive the development and refinement of the Frappe framework.
Community and Ecosystem: The open-source nature of both projects fosters a collaborative community. Contributions to Frappe often lead to enhancements in ERPNext and vice versa, creating a vibrant and shared ecosystem for business application development.
Leveraging ERPNext for Business Solutions
ERPNext can be leveraged to address a wide range of business challenges. Whether you’re a small business looking to streamline operations or a large enterprise seeking to integrate various departments, ERPNext provides a suite of tools to manage everything from sales and inventory to human resources and finances.
Setting up ERPNext for Different Business Domains
ERPNext caters to various business domains, providing modules and features to meet specific industry requirements. Setting up ERPNext involves configuring the system to align with different domains’ unique workflows, data structures, and business processes.
General Steps for Setting up ERPNext
In this section I will cover many of the tasks you need to get started using ERPNext.
1. Installation:
ERPNext can be installed on-premises or hosted on a cloud service.
ERPNext provides flexibility in deployment, so businesses must choose between installing it on-premises or hosting it on a cloud service.
Choosing between on-premises and cloud hosting for ERPNext depends on your organization’s specific needs, including control, scalability, cost, and ease of management. For most businesses, cloud hosting offers significant flexibility and reduced overhead advantages, but on-premises deployment may be preferred for those requiring complete control over their infrastructure.
Here’s a more detailed look at both options:
On-Premises Installation
On-premises installation is setting up ERPNext on your physical servers within your organization’s data center or office. It gives you complete control over the infrastructure, data security, and customization but requires more effort in server maintenance, backups, and updates.
Steps to Install On-Premises:
- Server Requirements:
- Operating System: Ubuntu 18.04 or 20.04 LTS (recommended)
- RAM: Minimum 4GB (for small deployments); 8GB+ (for larger deployments)
- Storage: SSD is preferred for faster performance
- CPU: 2 cores or more
- Installation:
- Use the easy Install script provided by Frappe to set up ERPNext quickly.
wget https://raw.githubusercontent.com/frappe/bench/develop/install.py
sudo python3 install.py --production --user frappe
- This script installs all the necessary components, including the Frappe framework, MariaDB, Redis, Nginx, and ERPNext.
- Management:
- You’ll need to handle server updates, security patches, backups, and scaling as your organization grows.
Cloud Hosting
Cloud hosting allows you to deploy ERPNext on a cloud service provider’s infrastructure. This option is ideal for businesses that want to reduce the overhead of managing physical servers, as the cloud provider handles much of the underlying infrastructure. It also offers greater flexibility and scalability.
Popular Cloud Services for Hosting ERPNext:
- Amazon Web Services:
- EC2 Instances: Deploy ERPNext on an EC2 instance with a pre-configured image or manually install it.
- RDS: Use Amazon RDS for the database backend, which offers automated backups and scaling.
- S3: Store backups and static assets in S3.
- Google Cloud Platform (GCP):
- Compute Engine: Like AWS EC2, you can deploy ERPNext on a virtual machine.
- Cloud SQL: Manage your ERPNext database with Google’s managed SQL service.
- Google Kubernetes Engine (GKE): Deploy ERPNext using containers for a more scalable approach.
- Microsoft Azure:
- Azure Virtual Machines: Deploy ERPNext on a VM, with options for scaling and managing the database through Azure SQL.
- Azure App Service: Use Azure App Service to deploy ERPNext in a more managed manner.
- Droplets: Quick and cost-effective way to deploy ERPNext using virtual private servers.
- Managed Databases: Use DigitalOcean’s managed database service to offload database management.
- Frappe Cloud (Official ERPNext Hosting):
- Frappe Cloud is the official cloud hosting service for ERPNext, offering a fully managed environment. It includes automatic updates, backups, and scaling with minimal management required from your side.
- SaaS Model operates on a Software-as-a-Service model, where you pay for the resources and services you use.
For this installation, we’ll use the easy install script for a quick setup, or manually install it on a server.
wget https://raw.githubusercontent.com/frappe/bench/develop/install.py
sudo python3 install.py --production --user frappe
2. Initial Configuration:
Set up your company details, including company name, address, and currency.
Configure users and roles according to your organizational structure.
3. Domain-Specific Modules:
ERPNext allows you to enable and configure modules specifically relevant to your business domain. This flexibility makes it suitable for various industries, from retail and manufacturing to healthcare and education.
For instance, in a retail Setup
Modules to Enable: Retail, Point of Sale (POS), Inventory, Sales, Accounts.
Configuration:
- Set up POS profiles and devices for each retail outlet.
- Configure pricing rules, discounts, and promotions.
- Manage inventory across multiple locations and warehouses.
Customizing ERPNext modules and workflows
ERPNext is very customizable, allowing businesses to tailor their modules and workflows to match their specific needs. Customizing forms and fields are a common way to make ERPNext align more closely with your unique business processes. Here’s how you can customize Forms and Fields of ERPNext:
Adding Custom Fields
When you first set up ERPNext, each module and form (called a “Doctype”) comes with predefined fields. These default fields cover general use cases across various industries. However, because each business has unique requirements, these fields might only sometimes capture all the necessary information.
Customization allows you to add fields specific to your business operations. For example, a manufacturing company might need a custom field to track specific raw material specifications, while a retail business might need a field to capture customer preferences.
1. Navigate to Customize Form:
Go to the ERPNext dashboard:
Navigate to the Customize Form tool under the search input.
Select the Doctype (form) you want to customize from the dropdown.
2. Add a Custom Field:
Click on Add Row to create a new custom field.
Enter the field label (the field’s name as it will appear on the form).
Choose the field type (such as “Data
,” “Select
,” “Date
,” “Check
,” etc.) based on the kind of information this field will capture.
For instance, if you’re adding a field for a serial number, you might choose the “Data
” type.
Set other properties, such as whether the field is mandatory, hidden, or read-only or if it should appear in reports.
Click on Save to apply your changes.
Modifying Existing Fields
ERPNext provides flexibility not just in adding new fields but also in modifying existing ones to suit your business. Whether you need to change the label of a field, adjust its type, or set default values, ERPNext makes it straightforward. Using custom scripts, you can further refine form behavior, adding logic that automatically validates or populates fields based on user input.
1. Access the Doctype:
Choose DocType List and select the Doctype you want to modify.
2. Edit Field Properties:
Change properties such as label, field type, and default values.
Save the changes.
3. Custom Scripts
ERPNext allows you to add client-side scripts to customize form behavior.
Adding Custom Scripts
1. Navigate to Client Script:
Go to Client Script under the Build
section.
2. Create a New Script:
Select the Doctype you want to customize.
Here, I selected the Account
Doctype.
Write JavaScript code to modify form behavior (e.g., validate fields, autofill values).
frappe.ui.form.on('Account', { refresh(frm) { frm.add_custom_button('Custom Action', function() { // Custom action code here }); } });
3. Customizing Workflows
Beyond fields and forms, you can also customize workflows to match your business processes. A workflow in ERPNext defines the sequence of steps that a document goes through, from the draft which is creation, to completion, including approvals and rejections.
Creating a Custom Workflow
1. Navigate to Workflow:
Choose Workflow List:
Then click on Add Workflow.
And then you can define your workflow using the dialog presented.
2. Define Workflow States:
Add different states a document can be in (e.g., Draft, Pending Approval, Approved).
3. Set Transition Rules:
Define the actions that move the document from one state to another.
Specify the roles allowed to perform these actions.
4. Apply Workflow to Doctype:
Select the Doctype to which the workflow applies (e.g., Purchase Order, accounting etc.).
Save the workflow.
Then you can see it in the list.
Custom Reports and Dashboards
ERPNext allows you to create custom reports to gain insights into your business data.
Creating a Custom Report
In this section I will show the steps needed to create a basic custom report.
1. Navigate to Report:
Go to Report List from the action list:
Then click on Add Report:
And now you have the basic structure of the report:
2. Define Report Parameters and other details:
Choose the Doctype for the report and select the type of report (e.g., Query Report, Script Report).
From there you will find a few more steps, including for Query Reports, write the SQL query to fetch data, of for a Script Report, write the Python code to generate the report. This is beyond the scope of this article as I simply want to show you where everything is located and help you get started. You can find more details on creating reports here on the ERPNext site..
Finally you will save the report and test it by running it.
Integrating Third-Party Applications with ERPNext
ERPNext provides integration capabilities, easily connecting with various third-party applications through RESTful APIs, webhooks, and custom scripts. These integrations can enhance ERPNext’s functionality and streamline business processes by leveraging external services such as payment gateways, email services, and other enterprise applications. I’ll show the API method of integration.
API Integration
ERPNext offers a comprehensive REST API that allows you to perform CRUD operations on most ERPNext objects. Here’s how you can use API integration:
Integrating with a Payment Gateway
Let’s integrate ERPNext with Stripe to process payments.
1. Generate API Keys in ERPNext
Navigate to User > API Access.
Generate API keys for secure access.
2. Install Stripe Python Library
pip install stripe
3. Create a Custom App in ERPNext for Stripe Integration
File: stripe_integration.py
import stripe import frappe stripe.api_key = 'your-stripe-secret-key' @frappe.whitelist() def create_payment_intent(amount, currency='usd'): intent = stripe.PaymentIntent.create( amount=int(amount), currency=currency, ) return intent.client_secret @frappe.whitelist() def handle_payment_webhook(request_data): event = None try: event = stripe.Event.construct_from( request_data, stripe.api_key ) except ValueError as e: # note that this will terminate processing frappe.throw("Invalid webhook data") if event.type == 'payment_intent.succeeded': payment_intent = event.data.object # Handle successful payment here. # Note that many applications # Will want to do more than just print out this
# to a screen. frappe.msgprint(f'Payment for {payment_intent.amount} succeeded.') return "Success"
4. Call the API from ERPNext
Create a custom button in the Sales Invoice form to initiate a payment using the Stripe API.
Custom Script: Custom Script for Sales Invoice
frappe.ui.form.on('Sales Invoice', { refresh: function(frm) { if (!frm.doc.__islocal && frm.doc.status !== 'Paid') { frm.add_custom_button(__('Pay Now'), function() { frappe.call({ method: 'path.to.stripe_integration.create_payment_intent', args: { amount: frm.doc.grand_total * 100, currency: frm.doc.currency.toLowerCase() }, callback: function(r) { if (r.message) { // Redirect to Stripe Checkout or handle client-side console.log('Client Secret:', r.message); } } }); }); } } });
Conclusion
ERPNext provides comprehensive tools for managing data, generating reports, and performing analytics. By leveraging features such as data import, standard and custom reports, dashboards, and analytics tools, businesses can effectively manage their data and gain valuable insights to drive informed decision-making.
The Frappe framework provides a powerful and flexible platform for customizing ERPNext. By setting up a development environment, creating custom apps and DocTypes, writing custom scripts, and integrating with external systems, you can tailor ERPNext to fit your business’s specific needs. This customization capability ensures that ERPNext can be adapted to various use cases, making it a versatile solution for enterprise resource planning.
The post Frappe and ERPNext: Leveraging ERP Capabilities for Business Solutions (Part I) appeared first on Simple Talk.