How to setup environment to create a new module

Thanks @pokoli
I’m looking through the documentation and trying to find the trytond/modules folder as mentioned in the ‘Modules’ section

Module Structure

A module is a directory in trytond/modules which contains at least two files:

In my docker instance I can see /var/lib/trytond/www but no ‘module’ folder
Where do I copy my ‘cloned’ module?
Or does it get applied via a hg process?
An overview of the module creation workflow would certainly be appreciated.

I just have not had any luck getting a non-docker instance of Tryton installed. If that’s that’s the path I need to take I’m sure I’ll need coaching to get a development environment setup.

Basic setup

For creating the basic folder structure and you can use cookie-cutter (need to install cookiecutter first via pip/system packet manager)

then you can execute:
cookiecutter hg+
cookiecutter will ask you some question (like the project name), then will create a folder with all the necessary thing to start developing with tryton


First you need to change the tryton.cfg; this file is responsible for:

  • tell witch version of tryton this module support
  • tell your tryton module dependecy
  • tell the xml file to include (the one that define the database record, not the views)

how to install your module

I strongly suggest to use a virtual-environment for development. The you can simply python install to install all your dependecy defined in the tryton.cfg (you can install the dependency manually if you want).
Every time you make a change you need to reinstall the module, unless you use a workaround (python develop doesn’t work unfortunally)

how install the module in editable mode (for developing it)

When developing, installing the module every time you modify it can be time consuming,
a sane way to solve this problem is to install it id editable mode:
python develop
This will not work if your module folder doesn’t match the module name!
This will create a simlink in the correct folder for you.

How to setup your playground/manual testing environment

Trytond needs a database, fortunately you can be lazy about it and use sqlite. For this you need create a config file, the minimum required is:


or optionally set the environment variable
export TRYTOND_DATABASE__PATH=/path/where/sqlite/dbs/are/stored
[explained in]

The only thing missing is to create a empty file in the /path/where/sqlite/dbs/are/stored folder, don’t forget to ad the .sqlite extention or tryton will not recognize it. You can have multiple sqlite db in the same folder.

touch /path/where/sqlite/dbs/are/stored/testplzignore.sqlite

Prime the database

You need to prime your database, this can be accomplished with the trytond-admin command.
This will create all the necessary table for tryton to work, and set the admin password.
The detail are explained in the documentation

# with the configfile
trytond-admin -c configfile.cfg -d dbfilename --all

#with the enviroment variable
#export TRYTOND_DATABASE__PATH=/path/where/sqlite/dbs/are/stored
trytond-admin -d dbfilename --all

where dbfilename is the filename of the db without the .sqlite extention.

Activate your module

After “priming” you need to activate your module, this can be done via the client gui or via command line:

#with the enviroment variable
#export TRYTOND_DATABASE__PATH=/path/where/sqlite/dbs/are/stored
trytond-admin -d dbfilename -u moduletoactivate --activate-dependecies

Update your module

if you modify some xml file, you need to update the db and usually relaunch the client. this can be archived with:

#with the enviroment variable
#export TRYTOND_DATABASE__PATH=/path/where/sqlite/dbs/are/stored
trytond-admin -d dbfilename -u moduletoupdate

This isn’t necessary it you modify just your python code.

Execute the tryton server (trytond)

You can execute the tryton server with:

# with the configfile
trytond -c configfile.cfg

#with the enviroment variable
#export TRYTOND_DATABASE__PATH=/path/where/sqlite/dbs/are/stored

If you don’t want to reload the tryton server on every change, you can use the --dev flag.
This flag will auto-reload your module every time tryton see a file-change in the trytond folder. If you created the simlink like above mentioned, trytond will reload changes every time you save your module. The command

#with the enviroment variable
#export TRYTOND_DATABASE__PATH=/path/where/sqlite/dbs/are/stored
trytond --dev

the tryton client

You can install the tryton clinet via pip, the only caviat is that you need to install pygobject first…
Thsi can be a problem inside a virtual enviroment, but just remember to install pygobject globally and make sure to create the virtualenviroment with the system-site-packages flag.

If you executed the tryton server locally, by default it will listen on (you can change it in the config file)
When starting the client, you need to specify:

  • host ( if the server is executed locally)
  • database name (The databse nabe is the filename of the sqlite db you primed before)
  • user (the only one is admin for the moment, the password is the one you inputted in the db priming stage)


I suggest you read the guide here:

1 Like

Thank you Luca.
I’m attempting to setup a virtual environment by following this - is it the best set of steps to follow?

When I try this command

trytond/bin/trytond-admin -d test_db -u ir res -v

I get (among other errors), this
UserWarning: Unable to create index with parameters
warnings.warn(‘Unable to create index with parameters’)

I was able to get the steps in
Create a virtual environment:
Install dependencies:
Test trytond server:
completed without error, however

That guide is a work in progress. I hope to get more time soon to improve the patch submitted to review, however I’ve good news for you:

You’re doing well so that warning messages are due to nature of sqlite database, if you would set up the environment on postgres database you will not see those warnings.

Hi Jose.
I think I’m getting close.
In your guide, when I get to the Test tryton client stage I get an error
Namespace Gtk not available
I’m assuming because this Tryton client is a desktop GUI and I’m trying to set this up on a console server

Do I need to skip this part and install sao instead?
I have cloned but I’m not really confidant about it’s needed configuration

This from your guide


In case you want to develop with web client enter directory where sao was unpackaged and install it:

$ npm install
$ grunt

Create symlink to sao:

$ ln -s ~/path/to/directory/where/sao/is/placed www

Finally, test it setting localhost:8000 as the url in your browser.

Do I need an absolute path for the www in the ln command?
How do I set the listener from localhost to so it’s available to browse from my network?

Answered my own question about the listener.




But I now get this from the browser
What am I missing?

Method Not Allowed

The method is not allowed for the requested URL.

OK, I’ve gotten a workable system and can browse and log into the Tryton WebUI
Here’s what I diid:
I installed (apt) postgres & (pip) psycopg2,
created a postgres tryton role and DB,
‘primed’ the new DB,
and updated my trytond.conf as follows

uri = postgresql://tryton:tryton@localhost/
path = /var/lib/trytond


I’ll start putting together the blue print for my proposed EDI module, next.
Thanks for the help!

I suspect you where using the sqlite backend and which did not support all features so we raise a warning to notice that the feature is not supported on sqlite.

After setting up and running and testing startup of trytond, I’ve cd’d into the tryton-env/modules/sale folder and ran
python install

everything appears to have completed without error but I still only see the ir and res modules in the WebGUI

Anybody have any tips on how to add the basic modules for sales from a source install?

This appears to have fixed it

trytond/bin/trytond-admin -c trytond.conf -d tryton -u ir res account_invoice_stock party account account_invoice currency company product stock account_product country sale -v

I’m missing something here. How is this done? In what context? After activating the virtual environment? From what folder?

Cookie cutter is a python package/script for create a folder with file based on a template. You need to install cookiecutter first via pip (pip install cookiecutter)
The hg+ Is the template that cookiecutter will download.
The result is a folder with your project name, and all the basic file pre-populated.

This is not necessary, but it helps speed the module, and eliminate the need to write the boilerplate manually.

Don’t need to be in a virtual environment. This will just setup the folder structure.

Thanks. I see now.
I needed to do this prior - obvious mistake on my part
pip install cookiecutter
then the cookiecutter command works and prompts for the template values

After developing the module created by the above command, when I’m ready to deploy it, I would
python install
and then use the trytond-admin with the -u to activate it in the WebGUI?

Yes, but when developing I recommend using python develop in order to install the module in development module so you don’t need to reinstall the package for every change you make on it.

1 Like

Doesn’t work for me. This is because
So you need to create the simlink manually like I explained

yes, you will activate/update the module with the -u, but not forget to add all the dependecies. the better option is to add the --activate-dependecies:

#with the enviroment variable
#export TRYTOND_DATABASE__PATH=/path/where/sqlite/dbs/are/stored
trytond-admin -d dbfilename -u moduletoactivate --activate-dependecies

Then the module will show up (in theory).

The folder should have the same name as the module name. Otherwise it does not work.

All this years… and now i understand why editable/develop mode is not working. Modified my developer guide accordingly.

1 Like