Basic coding guide for Frappe - ERPNext: Part 1

Alain Berger
Nov 26, 2017 · 11 min read

This is part 1 of a 2 part guide. Keep in mind that I am a farmer, not a programmer, so there are probably some errors or omissions. My hope is that the document will improve with comments and time.

Part 1 contains:

Part 2 contains:

Introduction

In 2014, I decided to start a business, and after 16 months of intense work to meet our goals as a startup, it was painfully evident that we needed at least a basic ERP (Enterprise Resource Planning) to help with all our administrative tasks. As customer orders increased, the lack of proper coordination broke that startup environment that is so crucial to success. We had all the tools at our disposal in this great age of Internet: broadband connection, mac mini desktops and laptop, virtual switchboard services with Android mobile devices, WhatsApp, Dropbox, Gmail and spreadsheet programs (both Excel and Google online sheets). So, what were we complaining about?

All those tools are great, but a well-managed company requires a specific workflow and corresponding tools. Therefore, we needed something that could help us manage customers, suppliers, accounting, etc. At this point, the picture became more complex again: Quickbooks for accounting, Salesforce for customers, and we're back to the beginning! Separate applications that try to solve a single problem.

After the Christmas holidays of 2015, I was clear that we needed to integrate all this. For 2016, I had proposed objectives to solve our problem of commercial coordination and all the problems generated by using separate applications, in addition to the new issuance of costs and administration of subscriptions: you must pay to use some of these services, and although the prices are appropriate, you still have to pay bills separately for everything: PayPal solves this. But still, it has line items for each service.

I looked for profitable solutions and opted for open source options. I saw things like Gnucash, OpenBravo, Odoo, etc. and I was not very convinced. The issue of integration was still an important issue for us. Yes, we could develop procedures for this, even so we would have to program connections between our solutions: use our spreadhseet files neatly with Dropbox, integrate our mobile devices with Salesforce or similar, and maybe even program some kind of framework to integrate everything together . But wait, now we have to schedule something and we need to host it somewhere. We need to hire a programmer or two and invest some money to create this framework.

Trying to combine everything, find solutions and find only more problems exhausted me and the team. The idea of ​​the frame was brilliant, but nobody had done it, right? Incorrect! Someone had already addressed this problem in particular, and had done so majestically.

The answer came in February with a dark post in the forum after a Google search. The name: ERPNext , based on Frappé framework, a web application developed in Python and JavaScript.

Implementation

Fast forward to June 2017, and we had already implemented a self-hosted version of this wonderful Open Source software. We opted for our own accommodation because I knew that we would modify it to a large extent. Integrates everything else beautifully, but the basic elements do it by itself: accounting, CRM, sales workflow, purchase and suppliers, stock management, etc.

We love the fact that it not only solved our basic integration needs, but also gave us more functions than we thought we would need: management tools, allocation and attachment of Bill-of-Materials: I can assign invoices to specific users or attach scanned copies of printed articles to validate your electronic counterpart documents. The framework itself is designed to be simple, but allows complex process management.

An example

One problem I used to have in my previous job was to solve problems that arose when a remote location manager ordered the items to form a central shopping location, and the item took more than 200 days to finally arrive. Who was to blame? Did the farm not order the item on time, or specify exactly what and how much did it need? Or the central purchasing manager did not comply? We had innumerable arguments and occasionally ended up in an unfortunate attack of anger from the parties involved (including me, I have learned better since then). Now, an existing item in the stock module is requested by the person in charge at the remote location, and this alerts the purchasing manager. The clock is working since the article is requested. The purchasing manager receives a quote, or if it is a regularly ordered item, Issue the purchase order to the supplier. At the moment the purchase order is validated, the specific article request changes the status. It is no longer necessary to waste time advising the interested party that their article has been ordered, ERPNext does it automatically! Then, when the article is finally received, all the parties involved are informed. Then, the accounting can pick it up and complete the transaction, including payment. All this can be seen immediately in the accounting module and you can see the cash flow reflecting this automatically.

The software itself allows you to make customizations based on the user, with little programming knowledge. All software works in an open source stack as a web application, allowing you to make modifications if you wish. It also has a large community of users, implementers and developers.

I will not expand all the wonders of ERP. Follow this in this publication, because our purpose is to create a basic guide or a map to make modifications based on scripts to the software, one of its most powerful features.

Personalization

Since I started implementing it for our business, I had one goal in mind: to learn how to perform and eventually master custom software adaptations. All this to enable ERPNextto cover things such as consolidated declarations or taxes per unit of measure of article, or specific fiscal peculiarities of the country. The software, out of the box, is the only software that is already well advanced in the solution of many common or even peculiar commercial problems. Even today I'm still discovering new things that he can do, thanks to his frequent updates. Contrary to other custom-made commercial software, those with a custom software system will have to get used to a new type of problem: the updates they receive from the central development team, and not the other way around. What a great problem to have! Before, we used to wait for the developer to create the necessary customizations. In my previous job, They even caught us in a legal license fight that left the only developer willing, restricted by the court to update the current ERP software. Imagine that: You can not update Excel or Word because Microsoft is in a legal battle with one of the main developers. There is an error and you have to wait 5 years until the case is resolved (if it does). Everything that has gone withFrappé and the license structure of ERPNext based on GPL V3.0 .

Now we are happily operating all our transactions in ERPNext, and given its high personalization, I have decided to dedicate the time to expand the framework to meet our needs and solve specific problems of the country and the company.

Just read the instructions

Before starting, I must admit that, despite the large amount of resources available, as an occasional programmer, it took me some time to find the way to solve this ecosystem. How to learn to ride a bicycle or drive a car takes time.

So, this is my best attempt to write some instructions that help clarify how the whole framework works . I hope that by reading this, you can discover how to modify it to adapt it to your needs.

From hardware to fields: the whole stack

Hardware

Ideally, you want to run this on a server machine or in a cloud-based service. I suggest Amazon Web Services or Digital Ocean . If you want to test and develop (or even configure a live server or install it for use on a single computer), install a virtual machine such as Open Source VirtualBox from Oracle right now, within which you install the operating system.

TK Add information about networks with the box for a single machine

OS

The whole stack runs on Linux , specifically on Ubuntu . I suggest 16.04 LTS, but you can try any other version from 14.04 onwards. You can configure it in a server version for the real action, or if you want to develop it, use a desktop version of Ubuntu.

Software base

The frame

Frappé Bench : this is the web framework on which everything else works. The framework puts all the resources below (Hardware, Operating System and Base Software) to work together efficiently. Theoretically, you can run any application you want in the framework

Applications

ERPNext : all the commercial tools I mentioned above are executed directly in this specific application.

Modules

Each application has several modules that provide specific functionality. In the case of ERPNext, some examples of modules are Accounts, Purchase, Sale, Human Resources.

Doctype

Within each module, there is a collection of document types ( DocTypes) . A DocType collects data fields that fit a specific purpose. A purchasing module could have requests for materials, purchase orders or types of purchase receipt documents .

Docfield

Each type of document collects several fields to store data within it. A material request doctype will have fields for the item name or the request date, but only a purchase order will have information on the date an order is placed with the supplier. A third type of document, a purchase receipt may have the date on which the business receives the item. The three dates mentioned are different pieces of information. In this example, you can clearly see that by storing these different dates, you can determine the number of days between a material request, or the time it takes for the supplier to ship, or the complete delivery time from the request to the delivery.

Other tricks

The framework is well designed, allowing you to save time on certain tasks, such as duplicating previously existing unique document types, or adding custom fields, document types or scripts without modifying the source code. You can even use the framework itself to create new applications for the framework. The development occurs in unison between the web browser and a terminal connected to the server.

Before coding: set up your development environment


Before jumping to some coding, you need to configure your development environment on your favorite computer (s). Regardless of the configuration, I believe that having all these tools installed from the beginning makes the development environment excellent. Therefore, common to any configuration:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

I have two ways to configure a development environment: VirtualBox and Docker .

Development environment - VirtualBox

Assume that you are using Mac OS X. It is a graphical user interface that allows you to run a virtual computer inside your computer.

The steps to configure a VirtualBox ERPNext development environment are the following:

Development environment - Docker

Docker was launched in March 2013 and its goal is to reduce the overhead created by the previous method. A dockable container does not require or include a separate operating system, but uses resources from the local operating system.

The steps to configure an ERPNext development environment based on Docker are the following:

This link provides updated instructions on configuring frappe_docker .

https://github.com/frappe/frappe_docker

Installing ERPNext

In case you perform a installation from scratch, you should have the following:

For Linux:wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.pyFor Mac:curl "https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py" -o install.py

Once downloaded, run the script with:

python install.py --develop --user frappe

Once configured, you can start the bank from the /home/frappe/frappe-benchdirectory with the commandbench start

At this point, you need to set up a test site.

TK Setting up a test site

If you just want to try ERPNext, configure for production. All processes will be managed by nginxand supervisorautomatically.

sudo python install.py --production

Enabling Developer Mode

Once the installation has completed, you have to setup a test site. If you have installed a production server, then the site is already set, and you must enable developer mode. You can either edit the file on the terminal using Nano or your favorite text editor using Samba or with Docker. The file you need to edit is located here:

cd /home/frappe/frappe-bench/sites/[site_name]/site_config.json

Within the file, find the first .json element { and inside there will be two items: "db_name": "name", and "db_password": "password", so right after the last one, add a new line with the same indentation level, and then type:

"developer_mode": 1,

Make sure that you leave one space after the coma, and then save the file. If using nano: CTRL + X , Y , ENTER .

Frappé Thoughts

On Open Source, Design, Development and Community. By the makers of ERPNext.

    Alain Berger

    Written by

    Behold! There is a lot of lettuce (and software code too!)

    Frappé Thoughts

    On Open Source, Design, Development and Community. By the makers of ERPNext.