Contents
Helloworld Module
A little example how to create a new module and introduction API reference
Install Tryont Server
pip install trytond or python setup.py install
Run Tryton Server
python trytond -c /etc/trytond.conf
Example configuration file in etc directory
Install Tryton client (GTK Client)
pip install trytond or python setup.py install
Run Tryton Client
tryton
Install module
pip install helloword (available in Pypi or hg/git repo) or python setup.py install or cp helloworld trytond/modules/
- Reload modules list
python trytond -c /etc/tryton -u a_module -d databasename
- Install module using GTK client (or website client comming soon)
Module files
- CHANGELOG - COPYRIGHT | doc | - index.rst - helloworld.py - helloworld.xml | icons - __init__.py - INSTALL - LICENSE | locale | - ca_ES.po | - es_ES.po - MANIFEST.in - README - setup.py | tests | - __init__.py | - test_helloworld.py - tryton.cfg
Configuration module
tryton.cfg
[tryton]
version=2.7.0
depends:
ir
res
xml:
helloworld.xml
init file
from trytond.pool import Pool
from .helloworld import *
def register():
Pool.register(
Hello,
module='helloword', type_='model')Importat register class module
helloworld.py
- Fields
- Methods
- Static methods @staticmethod
- Class methods @classmethod
- transitions (workflow)
- Error messages
- ...
Class
Fields
Static method
Class method
Transactions
helloword.xml
- Views (tree, form, calendar, graph)
- MenĂºs
- Users
- Groups
- Permisions/Access
- Actions
You can move views (tree/form) in view directory (the file name is view id)
Views
1 <!-- Model Form -->
2 <record model="ir.ui.view" id="hello_view_form">
3 <field name="model">helloword.hello</field>
4 <field name="type">form</field>
5 <field name="arch" type="xml">
6 <![CDATA[
7 <form string="Hello" col="6">
8 <label name="name"/>
9 <field name="name"/>
10 </form>
11 ]]>
12 </field>
13 </record>
14
15 <!-- Model Tree -->
16 <record model="ir.ui.view" id="hello_view_tree">
17 <field name="model">helloword.hello</field>
18 <field name="type">tree</field>
19 <field name="arch" type="xml">
20 <![CDATA[
21 <tree string="Hello">
22 <field name="name"/>
23 </tree>
24 ]]>
25 </field>
26 </record>
Menu/Action
1 <record model="ir.action.act_window" id="act_hello_form">
2 <field name="name">Hellos</field>
3 <field name="res_model">helloword.hello</field>
4 </record>
5
6 <record model="ir.action.act_window.view" id="act_hello_form_view1">
7 <field name="sequence" eval="10"/>
8 <field name="view" ref="hello_view_tree"/>
9 <field name="act_window" ref="act_hello_form"/>
10 </record>
11 <record model="ir.action.act_window.view" id="act_hello_form_view2">
12 <field name="sequence" eval="20"/>
13 <field name="view" ref="hello_view_form"/>
14 <field name="act_window" ref="act_hello_form"/>
15 </record>
16
17 <menuitem parent="menu_helloword" action="act_hello_form" id="menu_hello_form"/>
Group/User
1 <record model="res.group" id="group_helloword_admin">
2 <field name="name">HelloWord Administration</field>
3 </record>
4 <record model="res.user-res.group" id="user_admin_group_helloword_admin">
5 <field name="user" ref="res.user_admin"/>
6 <field name="group" ref="group_helloword_admin"/>
7 </record>
Access
1 <record model="ir.model.access" id="access_helloword_hello">
2 <field name="model" search="[('model', '=', 'helloword.hello')]"/>
3 <field name="perm_read" eval="True"/>
4 <field name="perm_write" eval="True"/>
5 <field name="perm_create" eval="True"/>
6 <field name="perm_delete" eval="False"/>
7 </record>
Wizards
1 class TranslationExport(Wizard):
2 "Export translation"
3 __name__ = "ir.translation.export"
4
5 start = StateView('ir.translation.export.start',
6 'ir.translation_export_start_view_form', [
7 Button('Cancel', 'end', 'tryton-cancel'),
8 Button('Export', 'export', 'tryton-ok', default=True),
9 ])
10 export = StateTransition()
11 result = StateView('ir.translation.export.result',
12 'ir.translation_export_result_view_form', [
13 Button('Close', 'end', 'tryton-close'),
14 ])
15
16 def transition_export(self):
17 #TODO get export info
18 return 'result'
19
20 def default_result(self, fields):
21 #TODO get field
22 return {
23 'file': file_,
24 }
