Install Tryton on FreeBSD v13

Tryton is open source business software that can be used for enterprise resource management (ERP) and accounting. This post describes installing Tryton (and the PostgreSQL DBMS) on FreeBSD, and is one in a series on Tryton.

Tryton naming conventions:

  • Tryton (capitalized) is the Tryton system in totality.
  • trytond is the Tryton server daemon.
  • tryton (uncapitilized) is the Tryton desktop client. 
  • sao is the Tryton web client.
  • PostgreSQL is the database management system used by Tryton.

sao will not be installed in this tutorial.

This post is a Work in Process while being updated to describe installing Tryton 6.2 and PostgreSQL 14 on FreeBSD 13.

Install FreeBSD

Install FreeBSD v13 using suitable media and perform typical initial configuration. Create an initial admin user in the install wizard and include them in the wheel group. 

After booting into the new system and logging in as the admin user, copy a public ssh key for the admin user to ~/.ssh/authorized_keys and disable ssh password authentication in /etc/ssh/sshd_config for security.

% su - 
# vi /etc/ssh/sshd_config
...
# Change to no to disable PAM authentication
ChallengeResponseAuthentication no
...
# sudo service sshd restart

Update FreeBSD and package manager database for third-party software (pkg is initially only a shim which installs the current version of pkg).

# freebsd-update fetch
# freebsd-update install
# pkg update

Install sudo for the admin user to use for system administration.

# pkg install sudo

Configure sudo to allow the admin user (and all other members of the wheel group) to allow use without needing to enter a password for convenience (reasonable on a small system).

# visudo
...
## Uncomment to allow members of group wheel to execute any command
# %wheel ALL=(ALL) ALL

## Same thing without a password
%wheel ALL=(ALL) NOPASSWD: ALL

PostgreSQL

Tryton supports the SQLite DBMS for developer testing but for production PostgreSQL will be used.  

Install the latest version of PostgreSQL (currently 14.1). 

% sudo pkg install postgresql14-server

Edit /etc/rc.conf to start the server at startup

% sudo vi /etc/rc.conf
...
postgresql_enable="YES"

Create a new PostgreSQL database cluster and start the PostgreSQL server. 

% sudo /usr/local/etc/rc.d/postgresql initdb
% sudo service postgresql start
% sudo service postgresql status

The installation procedure creates a “postgres” user who owns the PostgreSQL files and the postgres server process. The provided configuration file /var/db/postgres/data14/postgresql.conf will allow access from localhost only. 

Use the PostgreSQL createuser command to create a tryton” super-user,

% sudo su postgres
$ createuser -sdrP tryton
Enter password for new role:
Enter it again:
$ exit
%

and restart PostgreSQL.

% sudo service postgresql restart

Confirm localhost can connect to the PostgreSQL server (“-W” prompts for user password).

% psql --username=tryton -W --list
Password: 
List of databases
   Name    | Owner    | Encoding | Collate | Ctype   | Access privileges
-----------+----------+----------+---------+---------+-----------------------
 postgres  | postgres | UTF8     | C       | C.UTF-8 |
 template0 | postgres | UTF8     | C       | C.UTF-8 | =c/postgres          +
           |          |          |         |         | postgres=CTc/postgres
 template1 | postgres | UTF8     | C       | C.UTF-8 | =c/postgres          +
           |          |          |         |         | postgres=CTc/postgres
(3 rows)
%

Python

Tryton has required Python 3 since v4.4, and Python 3.8 will have been installed as a dependency of postgresql14-server. However it will be convenient to create symlinks for accessing Python in a conventional manner.

% cd /usr/local/bin
% sudo ln -s python3.8 python3
% sudo ln -s pydoc3.8 pydoc3

Also bash and and pip will need to be installed. bash (the Bourne Again SHell) is required to use Python’s built-in venv module, which will be used to create a virtual environment for Tryton to avoid potential system dependency issues. pip (the Python package manager), will be used needed to install Tryton from PyPI (the Python Package Index). 

% sudo pkg install bash
% sudo pkg install py38-pip

Unlike python3, pip will be executed simply as pip (which is a symlink to the actual executable pip3.8 created by pip installation).

pip (at least on FreeBSD) must only be used to install packages into a user directory or virtual environment to avoid creating system inconsistencies, as per the pip post-install message. 

Install the Python SQLite package so Tryton can use SQLite for testing, 

 sudo pkg install py38-sqlite3

Install System Dependencies

Tryton makes use of libxml2, an XML C parser and toolkit, and libsxlt, an XSLT C library. 

% sudo pkg install libxml2
% sudo pkg install libxslt
% sudo pkg install graphviz

graphviz is not required unless sao is being installed.

Create a directory to install trytond

Create a directory to install trytond in. A dedicated user could be created to execute trytond, and their home directory used to install trytond and for storing document attachments, but for simplicity at this time a regular user and home directory will be used.

% sudo mkdir -p ~/work/trytond

Create virtual environment

% cd ~/work/trytond
% bash
% cd work/trytond
% bash
$ python3 -m venv env
$ source env/bin/activate
(env) ~/work/trytond$

Install trytond and modules

First install trytond, which provides basic Tryton server functionality.

(env) ~/work/trytond$ pip install trytond

Next install trytond modules for required user functionality. For managing parts, bills of materials, vendors and customers, the following modules will be sufficient.

  • trytond-product 
(env) ~/work/trytond$ pip install trytond-product

You can search PiPY for Tryton Framework to see all Tryton modules. Refine the search by adding “trytond” in the search field and sort the results by last updated, which will tend to put core modules towards the top of the list.

trytond modules can have dependencies, which will also installed when a module is installed. To see all the trytond modules which have been installed, use pip to list installed modules and grep for trydond.

(env) ~/work/trytond$ pip list | grep trytond
trytond 6.2.3
(env) ~/work/trytond$

Create a log directory for trytond.

% sudo mkdir /var/log/trytond
% sudo chown -R tryton:tryton /var/log/trytond

Create a json-rpc data directory for trytond

% sudo mkdir /var/run/trytond
% sudo chown -R tryton:tryton /var/log/trytond

Create trytond.conf

The Tryton configuration file trytond.conf is read by the Tryton server daemon trytond when it starts, and includes such site-specific data as:

  • computer addresses to respond to (jsonrpc).
  • username and password for the PostgreSQL “tryton” super-user.
  • Tryton “administrator” password (required to create, drop, backup or restore a database).
  • specify FreeBSD-specific directory paths

The trytond package does not include a trytond.conf file as trytond will use reasonable defaults, including using an SQLite database. However PostgreSQL is the recommended database for use cases other than basic testing, which will require creating a suitable trytond.conf file.

Create trytond.conf with the following content:

jsonrpc = *:8000,0.0.0.0:8000
jsondata_path = /var/run/trytond

db_type = postgresql
db_host = localhost
db_port = 5432
db_user = tryton
db_password = appleton

admin_passwd = appleton

pidfile = /var/run/trytond/trytond.pid
logfile = /var/log/trytond/trytond.log

data_path = /home/tryton

Start trytond

For production use an rc script should be created to control trytond. However for simplicity trytond will be started manually.

# ~/work/env/modules/bin/trytond

trytrond can be stopped using Ctrl-C.

Create and configure a new Tryton database

Download and install tryton, the Tryton desktop client for your system. The major and minor version of tryton must be the same as the major and minor version of trytond to connect.

Launch the Tryton client and access menu: File > Databases > New database.

Enter the Tryton server admin password (“admin_passwd” in trytond.conf) in the password field, then click Change beside the IP address and change the address to that of your server.

You must enter the password first, before changing the server address, because the Tryton client will attempt to connect to the server immediately after the server address is changed, and will report “Unable to connect” if the admin password was not already entered.

Enter the name of the database to create (e.g. “scc”) and the admin password for the database, then click Create.

Login to the new database as user “admin” and the password you entered to create the database. The Module Configuration Wizard will run automatically after login to configure the new database.

  • Add user (e.g. “Dale Scott”, login “dale”), optionally add permissions (you may need to update user permissions after installing modules, so this is optional at this point),
    • add Permissions: “Administration” (which will be the only permission group available)
    • add Rule: Read, Write, Create, Delete, Model: View Search (which will be the only rule available available).

The new Tryton database can now be configured for use as per Configuring Tryton (coming soon).

Using Duro PLM

I’m excited to be using Duro PLM for a new client. Duro is an exciting new cloud PLM and I was fortunate to have the company founder give me a tour of Duro just before Christmas. I will be posting about my experiences once I get my feet wet.

I also hope to compare using Duro to ERPNext for stabilizing and consolidating sub-assembly engineering BOMs (bill of materials) to create the top-level hierarchical BOMs for product SKUs, and for transfer to a CM (contract manufacturer).

Install ERPNext on FreeBSD 11.2 using VirtualBox

Search for other ERPNext-related posts. You may also visit the demo on dalescott.net.

The simplest way to “install” ERPNext on FreeBSD is to simply use the Virtual Image provided by the ERPNext project with VirtualBox.

The ERPNext project provides the Easy Install script for bare-metal installation but it has a number of Linux dependencies and will not work without changes on FreeBSD. Happily, the project also provides a fully configured virtual machine (based on Ubuntu Linux).

It may also be possible to use bhyve, the BSD hypervisor, with the virtual image, but the OVF file must first be converted to bhyve’s raw format.

Install VirtualBox

Install the virtualbox-ose-nox11 package for running headless virtual machines.

% sudo pkg install virtualbox-ose-nox11

The VirtualBox kernel module (virtualbox-ose-kmod) will also be installed, but it must be re-compiled from source and re-installed (at the very least, the system will crash when next re-booted once it has been configured to load the kernel module at boot). 

Update the ports collection to prepare for compiling the kernel module. 

# portsnap fetch update

If the ports collection has not been installed, install.

# portsnap fetch extract

The FreeBSD sources are required to compile the kernel module. If not already installed, install the FreeBSD sources.

% fetch ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/11.2-RELEASE/src.txz % tar -C / -xzvf src.txz

Compile and install the virtualbox-ose-kmod port. Make will first refuse to install the module because it is already installed (recall it was installed by being a dependency of virtualbox-ose-nox11). De-install the virtualbox-ose-kmod package, then re-install the newly compiled version.

% cd /usr/ports/emulators/virtualbox-ose-kmod
% sudo make
% sudo make install
% sudo make deinstall
% sudo make reinstall

Perform post-install configuration.

1) edit /boot/loader.conf to load the vboxdrv kernel module at boot,

# vi /boot/loader.conf
...
vboxdrv_load="YES"

2) increase AIO limits by editing /etc/sysctl.conf (my server is using AIO, for more information refer to the virtualbox-ose-nox11 pkg-message).

vfs.aio.max_buf_aio=8192
vfs.aio.max_aio_queue_per_proc=65536
vfs.aio.max_aio_per_proc=8192
vfs.aio.max_aio_queue=65536

Reboot the system to load the kernel module (or load it manually).

Make a mental note before doing an OS update to first edit /boot/loader.conf to not load the module. Otherwise the system will likely crash when next rebooted.

The user that VirtualBox runs as must be a member of the vboxusers group. For simplicity, I’ll run VirtualBox using my own username, although best practise would be to create a dedicated user.

# pw groupmod vboxusers -m dale

Edit /etc/rc.conf to run vboxwebsrv (the Virtual Box web interface daemon) using the provided startup script installed in /usr/local/etc/rc.d/

% sudo vi /etc/rc.conf

vboxwebsrv_enable="YES"
vboxwebsrv_user="dale"

and finally start the vboxwebsrv service.

% sudo service vboxwebsrv start
% sudo service vboxwebsrv status

The vboxmanage cli utility can be used to manage virtual machines but I will be using phpVirtualBox which provides a familiar GUI.

Install phpVirtualBox

phpVirtualBox can be installed from the FreeBSD ports collection but it currently has a dependency on PHP 7.1 while I have PHP 7.2. I installed phpVirtualBox manually to avoid pkg attempting to revert my PHP install to 7.1, and have not encountered any issues.

Download the latest release from the phpVirtualBox Github project . Follow the instructions in README.md file and on the wiki. Extract the project to /usr/local/www, and edit the configuration.

# vi /usr/local/www/phpvirtualbox/config.php

var $username = 'dale';
var $password = 'dale_login_password';

Configure the webserver to serve phpVirtualBox. I’m using the basic Apache 2.4 http server package. I added a virtual host definition to /usr/local/etc/apache24/extra/httpd-vhosts.conf to serve phpvirtualbox as a phpvirtualbox.dalescott.net.

<VirtualHost phpvirtualbox.dalescott.net>
  DocumentRoot "/usr/local/www/phpvirtualbox"
  <Directory "/usr/local/www/phpvirtualbox">
    allow from all
    Options None
    Require all granted
  </Directory>
</VirtualHost>

Change the default phpVirtualBox login password to something secure after logging in for the first time.

“Install” ERPNext

Download the desired ERPNext Virtual Machine image (*.ova).

% cd ~/downloads
% wget http://build.erpnext.com/ERPNext-Production.ova

Using phpVirtualBox, create a new vm by importing the downloaded ERPNext-Production.ova Virtual Image file (File/Import). The OVF includes port forwarding rules to forward client port 80 to host port 8080 (for serving ERPNext) and a rule to forward ssh from client port 22 to host port 3022 (for system administration).

Start the vm and then login to ERPNext from a browser (e.g. www.dalescott.net:8080) using the default credentials. The new site wizard will run and lead you through ERPNext configuration. Use a secure password when defining the initial (admin) user, and the wizard will delete the initial Administrator user (with default password) when complete. 

Once logged into ERPNext, setup email processing so that users will receive notifications outside of ERPNext. This will be valuable to understanding and appreciating ERPNext’s significant social aspect. You will also want to change the system login (i.e. ssh) password for “frappe” user to something secure (or disable password authentication entirely in favor of key-based authentication).

Cheers,
Dale

 

PLM using Parts&Vendors(TM)

Parts&VendorsTM was the seminal multi-user application in the late 90’s for embedded-electronics design teams to manage parts and assemblies. Running on Windows 98SE (originally), Parts&Vendors managed everything to do with embedded product development, including tracking parts, vendors, manufacturers, purchasing, supporting documents, and even rudimentary stock control for low-volume manufacturing. Teams worked efficiently with more cooperation, less bureaucracy, and at much lower cost, than possible with other solutions of the time.

Parts&Vendors was discontinued in January 2014, almost 15 years after it was released IMHO due to insurmountable technical debt. The Jet-type database did not handle clients crashing or high WAN latencies gracefully, and the codebase had not kept pace with Windows development practices.

Although no longer available, Parts&Vendors remains useful as a gold standard for evaluating PLM capabilities of ERP systems, such as ERPNext and webERP.

Parts&Vendors UX / UI 

Item Master Tab

Parts are accessed through the Item Master tab.

Item Details

Selecting a part provides detailed information on sources (vendors) as well as other useful information.

Files and URLs

Documents and web sites can be associated with a part,

making it easy to access local documents or a web page for reference.

Unfortunately PV did not include a document control user interface to keep things in order, or utilities to verify document paths or list parts referencing a particular file. The shared directory approach worked well for a small conscientious team, or one with a dedicated “librarian”, but not with a more “entrepreneurial” team (if you know what I mean <wink>).

Assemblies

A part may be grouped with others in an Assembly. You can easily tell what assemblies include a particular part in PV from the part’s Used On tab. 

It’s also easy to navigate from a part to a containing assembly, and back. This is also called traversing a product tree containing child parts and parent parts.

An assembly has a Parts List (aka Bill-of-Materials or BOM) that lists its child parts.

Purchasing

Parts can be easily ordered,

An order can accumulate parts until it is placed with a vendor, eventually resulting in a purchase Purchase Order (PO).

In a smaller organization, the engineering team often does the ordering themselves. In a larger organization, a “real” purchase order may need to be created in a separate parallel system (e.g. QuickBooks). The exact process will depend on an organization’s size, structure, and history.

Receiving

When the ordered parts arrive, the PO is retrieved and the order item marked received, 

which updates the stock on hand.

The assembly Parts List is one way to see when the parts necessary to build an assembly are in stock.

Manufacturing

Once all the child parts for an assembly are in stock, a “Kit List” is generated from the “Build” tab for manufacturing. Stock on hand can be reduced for the kitted items, and later increased for the finished assembly when completed. 

Customers

PV can also manage clients and client orders, although the functionality is not integrated with stock control and closing an order does not reduce quantity on hand of the ordered items. The functionality is understandable though given it was never a goal of PV to be a POS (Point Of Sale) or CRM (Customer Relationship Management) system. 

 

This completes a quick refresher of Parts&Vendors. In the next post I will compare ERPNext to Parts&Vendors.