Coder Social home page Coder Social logo

frappe-erpnext's Introduction

A guide-line for frappe and ERPNext framework

Official Frappe Documentation

Installation Process from ERPnext Community

Installation of Frappe framework and ERPNext on ubuntu 20.04 with python3 version


Prerequisite:

Python 3.6+
Node.js 12
Redis 5                                          (caching and real time updates)
MariaDB 10.3.x / Postgres 9.5.x                  (to run database driven apps)
yarn 1.12+                                       (js dependency manager)
pip 20+                                          (py dependency manager)
wkhtmltopdf                                      (version 0.12.5 with patched qt)  (for pdf generation)
cron                                             (bench's scheduled jobs: automated certificate renewal scheduled backups)
NGINX

Create a Virtual Environment on the local machine’s desired directory.

For my case, I’m going to create my project on Desktop’s subdirectory (ERPNext Folder).

Open the terminal by pressing: CTL + ATL+ T

Navigate into the Desktop by typing the command:

cd Desktop/

Create subfolder:

mkdir ERPNext

Install Virtual environment by:

sudo apt-get install python3-venv

Create python virtual environment:

python3 -m venv env

100002010000032D0000012B6AB89DD1260CD9C2

Install Node Js:

Install curl first:

sudo apt install curl

Download and execute the NodeSource installation script:

curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -

This will:

  • Add script of NodeSource signing key to your system,
  • Create an apt repository file,
  • Install all necessary packages and
  • Refresh the apt cache.

If you need another Node.js version, for example 12.x, change the setup_14.x with setup_12.x

10000201000004680000023975178A769CA9C0C3

Once the NodeSource repository is enabled, install Node.js and npm:

sudo apt install nodejs

Check Node Version

node --version

Check npm version

npm --version

10000201000004680000023978A0A5CF4B94B19A

Install yarn globally using node

sudo npm install -g yarn

10000201000004830000011909DADA1F43927846

Install git, python, and redis

sudo apt install git python-dev redis-server

100002010000046800000239D17A35A35AB20CDB

Install MariaDB

sudo apt-get install software-properties-common

If you are on Ubuntu version older than 20.04, run this before installing MariaDB:

apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8 add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://ftp.ubuntu-tw.org/mirror/mariadb/repo/10.3/ubuntu xenial main'

If you are on version Ubuntu 20.04, then MariaDB is available in default repo and you can directly run the below commands to install it

sudo apt-get update 
sudo apt-get install mariadb-server-10.3

1000020100000468000001DF171A126A852456B9

During this installation you'll be prompted to set the MySQL root password.

N.B: If you are not prompted, you'll have to initialize the MySQL server setup yourself. You can do that by running the command. (Remember: only run it if you're not prompted the password during setup.)

sudo mysql_secure_installation

You will be prompted with the following commands during the process

Enter current password for root (enter for none):

Change the root password? [Y/n] y

New password:

Re-enter new password:

Remove anonymous users? [Y/n] y

Disallow root login remotely? [Y/n] y

Remove test database and access to it? [Y/n] y

Reload privilege tables now? [Y/n] y

100002010000045600000227B0C40BBBE88F5152 1000020100000456000002271EA24C79B6C9BC36 100002010000045600000227570FD58ACDCA0E2F

It is really important that you remember this password, since it'll be useful later on.

You'll also need the MySQL database development files.

sudo apt-get install libmysqlclient-dev

1000020100000456000002274338C021506DA343

Now, edit the MariaDB configuration file.

sudo nano /etc/mysql/my.cnf

Add the following line to the end:

[mysqld]
innodb-file-format=barracuda
innodb-file-per-table=1
innodb-large-prefix=1
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci

[mysql]
default-character-set = utf8mb4

1000020100000456000002813505EB54324D2094


Restart MariaDB and enable it to automatically start at boot time.
sudo systemctl restart mariadb
sudo systemctl enable mariadb

Now, just restart the mysql service and and check status.

sudo service mysql restart
service mysql status

1000020100000456000002814561C2EC7A41157B

Install wkhtmltopdf:

sudo apt-get install xvfb libfontconfig wkhtmltopdf

(Activate the virtual environment with the command: source env/bin/activate)


Install Nginx and Redis:

sudo apt -y install nginx redis-server

Start Nginx and enable it to start at boot time.

sudo systemctl start nginx
sudo systemctl enable nginx

Start Redis and enable it to start at boot time.

sudo systemctl start redis-server
sudo systemctl enable redis-server

Install Frappe:

pip3 install frappe-bench

Confirm the bench installation by checking version

bench --version

Create your first bench folder.

bench init frappe-bench

10000201000005FD000001CD0FDE34F3CC332ED2 1000020100000363000002C91928EAB6FBC66FD9

While installing you might see some errors run the following command to install the dependency in order to avoid the error.

sudo apt-get install gcc python3-dev

Create a new Frappe site.

bench new-site <site_name> --db-name <site_database_name>

The above command will prompt you for the MySQL root password. Provide the password which you have set for the MySQL root user earlier. It will also ask you to set a new password for the administrator account. You will need this password later to log into the administrator dashboard.

10000201000004F80000015436722D45B2D09340

While creating the site you will be prompted to provide mysql password. If it prevents follow the following steps:

Database Login Issues

In some cases Database may not login, to rectify the issue Please Follow below steps

sudo nano /etc/mysql/my.cnf

Add the following lines at the end:

[mysqld]
skip-grant-tables

10000201000004F80000021A8F54FBEFDC0F7D86

Then Restart the service

sudo service mysql restart

Login to Mysql & follow the command

mysql -u root
use mysql
SELECT * FROM mysql.user WHERE user = 'root'; 

(Look at the top to determine whether the password column is called password or authentication_string)

UPDATE mysql.user SET authentication_string = PASSWORD('123456’) where user = 'root' and host = 'localhost'; - Use the proper password column from above

SELECT User, Host, plugin FROM user;

(if Plugin is not mysql_native_password, then set the plugin by the below command)

UPDATE user SET plugin='mysql_native_password' WHERE User='root';

FLUSH PRIVILEGES;

exit;

Remove the skip-grant-tables from /etc/mysql/my.cnf and restart the service & it's Done

Now download ERPNext installation files from the remote git repository using Bench.

bench get-app erpnext https://github.com/frappe/erpnext

10000201000004F8000001F60A62D5F2F1D54C59

Install ERPNext on your newly created site.

bench --site erp.testsite install-app erpnext

You can start the application immediately to check if the application installed successfully.

bench start

*You might face the error saying: Could not start up: Error in setup

In such case:

  • Make sure you didn't miss any dependencise.
cd /Desktop/frappe-bench
sudo chown -R user:user *

(For my case I’ve applied the following command since my user is mhfahad)

sudo chown -R mhfahad:mhfahad *

Now start the app with the command:

bench start






Create & Add Custom Application to site:

Creating a custom Module Here I'm going to create a module named Alesha Products

Creating the Module / app


Navigate to the project

bench new-app bigtech_product

This will ask you app specific information along with some default values

Once the installation is complete, you will have to install the app to the site. By default the site doesn't know the app details.

In order to install the application to the site you need to apply the following command.

bench --site <site_name> install-app <app_or_module_name>

In order to check installed apps of a particular site:

bench --site <site_name> list-apps

There are several site commands. To see all site commands.

bench --site <site_name> --help

The custom app/module is available in the site. Now we have to create doctype for the application to use.

In order to customize the site we need to run the site with enabled developer mode. To do that type:

bench --site <site_name> set-config developer_mode 1


DocType

In simple, DocType is the database table name of Frappe Framework. You will be directly interecting with database tabels using Frappe's DocType.

In our custom app/ module we will create two doctypes.

  1. Vendors
  2. Alesha Products

Creating DocType

While in Desk, type "doctype" in the search bar and select the DocType List option. You will be navigated to the DocType list where you will see a bunch of DocTypes. These are the DocTypes that are bundled with the framework.

The first doctype we will create is Vendors.

To create it, click on New.

  1. Enter Name as Alesha Vendors.
  2. Select Library Management in Module
  3. Add the following fields in the Fields table:
    Image(Attach Image)
    Full Name (Data) 
    Eamil (Data)    
    Contact (Text Editor)    
    Address (Data)    
    Bank Name (data)    
    Bank Account Name (data)    
    Bank Account Number (data)    
    Route (data)    
    Vendor Type (Select) Enter options: Shop and Company (Type Shop, hit enter, then Type Company)
  1. To save the form, Click save button

  2. add the following text to the auto naming field in the bottom so that the vendor name is unique throughout the list.

    BGT.VEN.#####

  3. In Form Settings section add the insert image to the text box. This lets frappe know which field of the table is image field so that it can handle that field in such way.

  4. In View Settings section, add which form field name you want to name the html view title name

    For my purpose I've used full_name field

  5. You can also restict the permission to different user roles from the Permission Rules section.

    Here I've added Business Developer who has the permission to read, write, create and delete permission. On the contrary, Operations role will have only read permission.

  6. Now save again. Reload the page by selecting Reload option from three dot button beside the save button.

  7. Go to vendor List

  8. Create Vendor

You will see that vandor with your given information has shown in the vendor list.

By Checking the Database You can also see new database table of named 'tabVendor'

Now Let's customize the Form look.

  1. Add row to vendor form fields table.
  2. Make the type Coumn Break
  3. Drag it to middle of the fields table rows.
  4. Save changes.
  5. Now go to add new vendor. You will see the long for is now splitted into two columns.
  6. We can also seperate a section of form to new sectin. In that case we have to add another row to the table as set the type Section Break
  7. Than drag the row before the row where you want to break the section.

Now Let's Add the Product DocType to our custom DocType


  1. Go to Doctype List.
  2. press + add DocType blue Button
  3. Enter Doctype Name
  4. Add Module Name
  5. Check Is Submittable Below Module selection text input. (This add three events to the form to save it)
  6. Add desired fields
  7. Modify Naming, Form Settings, View Settings, Permission Rules
  8. Save the form

Adding Web View for the Product

  1. Check the "Has Web View", Allow Guest to View, Index Web Pages for Search
  2. Add your DocType name into the Route input field e.g. Mart Product as mart_product.
  3. Add a new row to the Form Fields table named Route
  4. Make the field Hidden from row edit menu since it will be auto generated.
  5. Save Changes.

Adding Custom Module to Our admin deshboard with outher module list.

  1. Type workspace at searchbox and navigate to the Workspace List.

Screenshot from 2021-04-18 15-15-05

  1. press the + Add Workspace button. Screenshot from 2021-04-18 15-15-27

  2. Enter your Module Name that you want to call within.

  3. Select the Module for the Module list

  4. Select Category

  5. Enter Icon name that you want to represent your app or leave blank

  6. leave Onboarding blank

  7. check Is Standared from the right section

  8. Give Dashboards sectionlabel a name and add chart to teh charts row.

  9. Add Module specific all doctypes to the shortcut section and link them (The System will suggest all of the names, No need to memorise or else.)

  10. Add Link Cards similarly.

Screenshot from 2021-04-18 15-16-46

  1. Save and reload.
  2. Now go to the admin home page.
  3. Make a Hard Refreash or press CTL + SHIFT + R

You can see your Custom Module at the Left side of all module lists with your Given name and Icon along with

Screenshot from 2021-04-18 15-17-03




Upgrading Frappe & ERPnext Version

Standared Process and best practice but slower.

bench switch-to-branch version-13 frappe erpnext --upgrade

Please use this for production server

This needs to be nevigated into the app of the project.

git pull upstream version-13

Preferred Process only for development server.

bench get-app --branch=version-13 frappe

bench get-app --branch=version-13 erpnext

N.B: Please do not use this in production server

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.