By default there is only the JSON-RPC and XML-RPC api. This is the generic API that the clients used. (It is not yet fully documented but available methods are defined in __rpc__ attribute of each object).
But usually if you create a dedicated client, you will want to define your own API for it. This can be done per module by registering route: User Application — Tryton server. But you must be careful to manage authentication, access etc. using the provided wrappers.
A grep in the source files show plenty on __rpc__ definition. trytond.model.Model has some defined by default.
It is just a matter to apply decorator on the method and ensure that the file where the method is defined is imported by __init__.py. The Tryton convention is to put them in a routes.py file and to import it in __init__.py like in the timesheet module.
#__init__.py
from trytond.pool import Pool
from test import *
__all__ = ['register']
def register():
Pool.register(
module='jay_module', type_='model')
Pool.register(
module='jay_module', type_='wizard')
Pool.register(
module='jay_module', type_='report')
and tryton.cfg
[tryton]
version=5.6.1
depends:
ir
xml:
After that, I installed the module and updated the module list also enabled it in Administration. Then I tried running in postman and got this error. 405 Method Not Allowed
Thanks ced,
I am sorry, I pasted the code incorrectly on the forum. But now I corrected it and replaced the package import in my files too. I also reinstalled the module and updated it in modules-list.
Still I am getting the same error of 405 Method not Allowed. Am I missing any step? I don’t know.
I think I can talk on behalf of those, who want to add simple user application, extracting just some basic data from Tryton, without reading and learning the whole source code. The User Application — trytond latest documentation is good starting point, but an example showing how data can be extracted from Tryton would be great. I know this is a job someone experienced in Tryton has to do with no direct benefit, but I think there may be indirect benefits even for the Tryton gurus in long term.
I have the same issue, using a very similar module. The module is imported only after I performed some request using the GUI client. When restarting the server the module is not imported and the endpoint is not reachable.
(I added a print statement into the module so I can see when it is imported.)
So this comes down to the question: How can I make trytond import all activated modules on start?