LEFT | RIGHT |
1 .. _topics-modules: | 1 .. _topics-modules: |
2 | 2 |
3 ======= | 3 ======= |
4 Modules | 4 Modules |
5 ======= | 5 ======= |
6 | 6 |
7 The modules of Tryton extend the functionality of the platform. The server | 7 The modules of Tryton extend the functionality of the platform. The server |
8 comes by default with only a basic functionality included in those modules: | 8 comes by default with only a basic functionality included in these modules: |
9 ``ir``, ``res``, ``webdav``, ``workflow``. | 9 ``ir``, ``res``, ``webdav``, ``workflow``. |
10 | 10 |
11 Module Structure | 11 Module Structure |
12 **************** | 12 ================ |
13 | 13 |
14 A module is a directory in trytond/modules that contains at least two files: | 14 A module is a directory in trytond/modules which contains at least two files: |
15 | 15 |
16 * ``__init__.py``: a Tryton module must be a Python module. | 16 * ``__init__.py``: a Tryton module must be a Python module. |
17 | 17 |
18 * ``__tryton__.py``: a Python file that describes the Tryton module. | 18 * ``__tryton__.py``: a Python file that describes the Tryton module. |
19 | 19 |
20 ``__init__.py`` file | 20 ``__init__.py`` file |
21 ^^^^^^^^^^^^^^^^^^^^ | 21 -------------------- |
22 | 22 |
23 It is the Python ``__init__.py`` to define a module. It must import all the | 23 It is the Python ``__init__.py`` to define a module. It must import all the |
24 python files from the module. | 24 Python files from the module. |
25 | 25 |
26 | 26 |
27 ``__tryton__.py`` file | 27 ``__tryton__.py`` file |
28 ^^^^^^^^^^^^^^^^^^^^^^ | 28 ---------------------- |
29 | 29 |
30 It is a Python file that must contain only one dictionary with those keywords: | 30 It is a Python file that must contain only one dictionary with those keywords: |
31 | 31 |
32 * ``name``: The name of the module. | 32 * ``name``: The name of the module. |
33 | 33 |
34 * ``name_language_code``: The name of the module in the language code. | 34 * ``name_language_code``: The name of the module in the language code. |
35 | 35 |
36 * ``version``: The version number of the module. | 36 * ``version``: The version number of the module. |
37 | 37 |
38 * ``author``: The author name of the module. | 38 * ``author``: The author name of the module. |
39 | 39 |
40 * ``email``: The email address of the author (optional). | 40 * ``email``: The email address of the author (optional). |
41 | 41 |
42 * ``website``: The url of the website for the module (optional). | 42 * ``website``: The url of the website for the module (optional). |
43 | 43 |
44 * ``description``: A long description of the module. | 44 * ``description``: A long description of the module. |
45 | 45 |
46 * ``description_language_code``: The long description in the language code. | 46 * ``description_language_code``: The long description in the language code. |
47 | 47 |
48 * ``depends``: A list of modules on which the module depends. | 48 * ``depends``: A list of modules on which this module depends. |
49 | 49 |
50 * ``xml``: The list of the XML files of the module. They will be loaded at | 50 * ``xml``: The list of the XML files of the module. They will be loaded in |
51 the installation or update of the module. | 51 the given order at the installation or update of the module. |
52 | 52 |
53 * ``translation``: The list of csv files that contain the translation. The | 53 * ``translation``: The list of csv files that contain the translation. The |
54 name of the files must be the language code. | 54 name of the files must be the language code. |
55 | 55 |
56 | 56 |
57 Here is an example: | 57 Here is an example: |
58 | 58 |
59 .. highlight:: python | 59 .. highlight:: python |
60 | 60 |
61 :: | 61 :: |
(...skipping 17 matching lines...) Expand all Loading... |
79 "address.xml", | 79 "address.xml", |
80 "contact_mechanism.xml", | 80 "contact_mechanism.xml", |
81 ], | 81 ], |
82 'translation': [ | 82 'translation': [ |
83 'fr_FR.csv', | 83 'fr_FR.csv', |
84 'de_DE.csv', | 84 'de_DE.csv', |
85 'es_ES.csv', | 85 'es_ES.csv', |
86 ], | 86 ], |
87 } | 87 } |
88 | 88 |
89 Python files | 89 Python Files |
90 ************ | 90 ============ |
91 | 91 |
92 The Python files define the Models for the modules. | 92 The Python files define the models for the modules. |
93 | 93 |
94 XML files | 94 XML Files |
95 ********* | 95 ========= |
96 | 96 |
97 The XML files define data that will be inserted into the database. | 97 The XML files define data that will be inserted into the database. |
98 | 98 |
99 There is an rnc for those files stored in ``trytond/tryton.rnc``. | 99 There is an rnc for those files stored in ``trytond/tryton.rnc``. |
100 | 100 |
101 The following snippet gives a first idea of what an xml file looks: | 101 The following snippet gives a first idea of what an xml file looks: |
102 | 102 |
103 .. highlight:: xml | 103 .. highlight:: xml |
104 | 104 |
105 :: | 105 :: |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 147 |
148 * ``record``: Create a record of the model defined by the attribute | 148 * ``record``: Create a record of the model defined by the attribute |
149 ``model`` in the database. The ``id`` attribute can be used to refer to | 149 ``model`` in the database. The ``id`` attribute can be used to refer to |
150 the record later in any xml file. | 150 the record later in any xml file. |
151 | 151 |
152 * ``field``: Set the value of the field with the name defined by the | 152 * ``field``: Set the value of the field with the name defined by the |
153 attribute ``name``. | 153 attribute ``name``. |
154 | 154 |
155 Here is the list of attributes: | 155 Here is the list of attributes: |
156 | 156 |
157 * ``search``: Only for relation field, it contains a domain on which | 157 * ``search``: Only for relation field. It contains a domain which is |
158 searching for the first record and use it as value. | 158 used to search for the value to use. The first value found will be |
| 159 used. |
159 | 160 |
160 * ``ref``: Only for relation field, it contains an xml id of the | 161 * ``ref``: Only for relation field. It contains an xml id of the |
161 relation to use as value. It must be prefixed by the module name with | 162 relation to use as value. It must be prefixed by the module name with |
162 an ending dot, if the record is defined in an other module. | 163 an ending dot, if the record is defined in an other module. |
163 | 164 |
164 * ``eval``: Python code to evaluate and use result as value. | 165 * ``eval``: Python code to evaluate and use result as value. |
165 | 166 |
166 * ``type``: If set to xml, it will use the CDATA content as value. | 167 * ``type``: If set to xml, it will use the CDATA content as value. |
| 168 |
| 169 .. note:: |
| 170 Field content is considered as a string. So for fields that require |
| 171 other types, it is required to use the ``eval`` attribute. |
| 172 .. |
167 | 173 |
168 | 174 |
169 * ``menuitem``: Shortcut to create ir.ui.menu records. | 175 * ``menuitem``: Shortcut to create ir.ui.menu records. |
170 | 176 |
171 Here is the list of attributes: | 177 Here is the list of attributes: |
172 | 178 |
173 * ``id``: The id of the menu. | 179 * ``id``: The id of the menu. |
174 | 180 |
175 * ``name``: The name of the menu. | 181 * ``name``: The name of the menu. |
176 | 182 |
177 * ``icon``: The icon of the menu. | 183 * ``icon``: The icon of the menu. |
178 | 184 |
179 * ``sequence``: The sequence value used to order the menu entries. | 185 * ``sequence``: The sequence value used to order the menu entries. |
180 | 186 |
181 * ``parent``: The xml id of the parent menu. | 187 * ``parent``: The xml id of the parent menu. |
182 | 188 |
183 * ``action``: The xml id of the action linked to the menu. | 189 * ``action``: The xml id of the action linked to the menu. |
184 | 190 |
185 * ``groups``: A list of xml id of group, that have access to the menu, | 191 * ``groups``: A list of xml id of group, that have access to the menu, |
186 separated by commas. | 192 separated by commas. |
187 | 193 |
188 * ``active``: A boolean telling if the menu is active or not. | 194 * ``active``: A boolean telling if the menu is active or not. |
LEFT | RIGHT |