So, I know how to make a module with cookiecutter, but how do i really install it? I mean should I make them in /home/pathos/path/d/lib/python3.12/site-packages/trytond/modules here? And then I run the admin-tryton stuff?
And theres another question. I have several modules I want to try that I donβt install with pip, how do I install it without having a conflict? Thank you so much.
Have a look at the module tutorial.
There most of your questions are answered.
Edit: Recommended installation method depends on what you are trying to do.
While that can work, it is strongly discouraged.
For testing and development you will find the following in the module tutorial: python3 -m pip install --use-pep517 --editable opportunity
After you have installed/added a module you need to run: trytond-admin -c trytond.conf -d databasename -m. -m updates the module list.
After adding or modifying it is necessary to restart the server so that the new code can be read, unless you are using trytond --dev.
Official tryton modules are designed to not conflict, but you do need to mind other module dependencies and external python dependencies.
Just to be sure, suppose I already make a whole module in trytond/modules, then in the folder i run python3 -m pip install --use-pep517 --editable my_module_name?
and another question can i modify official tryton modules?? and if i can edit my module/official module should i run this again trytond-admin -c trytond.conf -d database name -m? Thank you so much for answering.
Either you install using the above command, or you put the directory containing the module in the trytond/modules directory, not both.
I had the same idea when I started out using tryton.
You CAN, but it will become a nightmare to maintain.
Tryton modules are designed to be extended, so you can extend or override most aspects of a module without actually changing the original module. This is also covered in the module tutorial.
I strongly suggest you to not do this. This is mixing installation and development. You will run into troubles more quickly than you think and you will end in a nightmare.
I suggest to:
use a project directory per module
install trytond in a virtual environment
activate the virtual environment
install your module in the virtual environment (using pip like @dotbit has shown)
If your module depends on other custom modules, consider using a requirements.txt file to install these prior to installing your module
For modifying official modules: Use an own custom module containing the modifications.
I have made an env for this and i installed some official modules in that env. The modules are installed in myenv/lib/python/site-packages/trytond/modules/
In modulesβ path there are gnuhealth modules and official modules. Since I want to develope my own modules should I make my custom module in that exact path? Or I could create another path for my custom modules?
I get the gist of these, thank you. So i should run python3 -m pip install --use-pep517 --editable my_module_name with every name? I could not do this bundle?
P.S: I already did what you told: and after i run trytond-admin -c trytond.conf -d my_database -m this errror shown: OSError: File not found : /home/username/.virtualenvs/folder_name/lib/python3.10/site-packages/trytond/modules/absensi/tryton.cfg
This: ls /home/username/.virtualenvs/folder_name/lib/python3.10/site-packages/trytond/modules/absensi/tryton.cfg
Result in: ls: cannot access '/home/username/.virtualenvs/folder_name/lib/python3.10/site-packages/trytond/modules/absensi/tryton.cfg': No such file or directory
But that was because absensi is a custom module, and why they would read a custom in trytond/modules/??
Of course I have trytond.cfg inside absensi. But somehow it could not read the trytond.cfg
because this path: /home/username/.virtualenvs/folder_name/lib/python3.10/site-packages/trytond/modules/absensi/tryton.cfg is not the path of absensi modules.
It seems that I have confused you with the trytond/modules directory, and for that I apologize.
There are multiple entry-points to a module depending on installation method, one of which is the module directory inside trytond directory.
It should be tryton.cfg.
Perhaps an old version of the module which is no longer there is registered in the database.
Are you using an old database, or starting a new one?
I would recommend checking that the module is installed using pip list and starting with a new database.
I try to run trytond-admin -c configuration -d databasename --all after installing with $ python3 -m pip install --use-pep517 --editable absensi it keep showing error like this:
(myvenv) tst@DESKTOP-QK8AUMD:~/mydir$ trytond-admin -c configuration -d database name
Traceback (most recent call last):
File "/home/tst/.virtualenvs/virtualname/bin/trytond-admin", line 23, in <module>
admin.run(options)
File "/home/tst/.virtualenvs/virtualname/lib/python3.10/site-
packages/trytond/admin.py", line 53, in run
pool.init(update=options.update, lang=list(lang),
File "/home/tst/.virtualenvs/virtualname/lib/python3.10/site-packages/trytond/pool.py",
line 152, in init
self.start()
File "/home/tst/.virtualenvs/virtualname/lib/python3.10/site-packages/trytond/pool.py",
line 105, in start
register_classes()
File "/home/tst/.virtualenvs/virtualname/lib/python3.10/site-
packages/trytond/modules/__init__.py", line 338, in register_classes
for node in create_graph(get_module_list()):
File "/home/tst/.virtualenvs/virtualname/lib/python3.10/site-
packages/trytond/modules/__init__.py", line 147, in create_graph
info = get_module_info(module)
File "/home/tst/.virtualenvs/virtualname/lib/python3.10/site-
packages/trytond/modules/__init__.py", line 85, in get_module_info
with tools.file_open(os.path.join(name, 'tryton.cfg')) as fp:
File "/home/tst/.virtualenvs/virtualname/lib/python3.10/site-
packages/trytond/tools/misc.py", line 78, in file_open
raise IOError('File not found : %s ' % name)
OSError: File not found : /home/tst/.virtualenvs/virtualname/lib/python3.10/site-packages/trytond/modules/absensi/tryton.cfg
This error message is often misleading. This often means that your module fails to import (due to an error in your module). Just add a raise in front of line 77 in trytond/tools/misc.py. nly use this in your development environment!
Thank you @htgoebel, I will keep that in mind. That was beyond my knowledge. @mahija The technique I use to avoid such errors is to make really small steps, then test and when you get an error you know which step produced the error.
I assume the link you gave me was trytond 7.2. I forgot to mention it was trytond 6.0 and the line in misc.py is a bit differen(that already bin raised)t:
if subdir:
if (subdir == 'modules'
and (name.startswith('ir' + os.sep)
or name.startswith('res' + os.sep)
or name.startswith('tests' + os.sep))):
name = secure_join(root_path, name)
else:
name = secure_join(root_path, subdir, name)
else:
name = secure_join(root_path, name)
for i in (name, egg_name):
if i and os.path.isfile(i):
return io.open(i, mode, encoding=encoding)
raise IOError('File not found : %s ' % name)
Oh, you are still on 6.0. AFAIU you are using GnuHealth and assume GnuHealth is still on 6.0. Otherwise Iβs strongly suggest to start new projects with the current TLS version.
In 6.0 the behavior was quite different and even worse. Since there are many possibilities why this can fail, I suggest to add this before line 42 and step through the code.