- Change select on fields into Boolean - Change format of search_value on ir.action.act_window review95002
195 lines
5.6 KiB
ReStructuredText
195 lines
5.6 KiB
ReStructuredText
.. _topics-modules:
|
|
|
|
=======
|
|
Modules
|
|
=======
|
|
|
|
The modules of Tryton extend the functionality of the platform. The server
|
|
comes by default with only a basic functionality included in these modules:
|
|
``ir``, ``res``, ``webdav``, ``workflow``.
|
|
|
|
Module Structure
|
|
================
|
|
|
|
A module is a directory in trytond/modules which contains at least two files:
|
|
|
|
* ``__init__.py``: a Tryton module must be a Python module.
|
|
|
|
* ``__tryton__.py``: a Python file that describes the Tryton module.
|
|
|
|
``__init__.py`` file
|
|
--------------------
|
|
|
|
It is the Python ``__init__.py`` to define a module. It must import all the
|
|
Python files from the module.
|
|
|
|
|
|
``__tryton__.py`` file
|
|
----------------------
|
|
|
|
It is a Python file that must contain only one dictionary with those keywords:
|
|
|
|
* ``name``: The name of the module.
|
|
|
|
* ``name_language_code``: The name of the module in the language code.
|
|
|
|
* ``version``: The version number of the module.
|
|
|
|
* ``author``: The author name of the module.
|
|
|
|
* ``email``: The email address of the author (optional).
|
|
|
|
* ``website``: The url of the website for the module (optional).
|
|
|
|
* ``description``: A long description of the module.
|
|
|
|
* ``description_language_code``: The long description in the language code.
|
|
|
|
* ``depends``: A list of modules on which this module depends.
|
|
|
|
* ``xml``: The list of the XML files of the module. They will be loaded in
|
|
the given order at the installation or update of the module.
|
|
|
|
* ``translation``: The list of csv files that contain the translation. The
|
|
name of the files must be the language code.
|
|
|
|
|
|
Here is an example:
|
|
|
|
.. highlight:: python
|
|
|
|
::
|
|
|
|
{
|
|
"name" : "Party",
|
|
"version" : "0.0.1",
|
|
"author" : "B2CK",
|
|
'email': 'info@b2ck.com',
|
|
'website': 'http://www.tryton.org/',
|
|
"category" : "Generic",
|
|
"description": "Define parties, addresses and co.",
|
|
"depends" : [
|
|
"ir",
|
|
"res",
|
|
"country",
|
|
],
|
|
"xml" : [
|
|
"party.xml",
|
|
"category.xml",
|
|
"address.xml",
|
|
"contact_mechanism.xml",
|
|
],
|
|
'translation': [
|
|
'fr_FR.csv',
|
|
'de_DE.csv',
|
|
'es_ES.csv',
|
|
],
|
|
}
|
|
|
|
Python Files
|
|
============
|
|
|
|
The Python files define the models for the modules.
|
|
|
|
XML Files
|
|
=========
|
|
|
|
The XML files define data that will be inserted into the database.
|
|
|
|
There is an rnc for those files stored in ``trytond/tryton.rnc``.
|
|
|
|
The following snippet gives a first idea of what an xml file looks:
|
|
|
|
.. highlight:: xml
|
|
|
|
::
|
|
|
|
<?xml version="1.0"?>
|
|
<tryton>
|
|
<data>
|
|
<record model="res.group" id="group_party_admin">
|
|
<field name="name">Party Administration</field>
|
|
</record>
|
|
<record model="res.user" id="res.user_admin">
|
|
<field name="groups" eval="[('add', ref('group_party_admin'))]"/>
|
|
</record>
|
|
|
|
<menuitem name="Party Management" sequence="0" id="menu_party"
|
|
icon="tryton-users"/>
|
|
|
|
<record model="ir.ui.view" id="party_view_tree">
|
|
<field name="model">party.party</field>
|
|
<field name="type">tree</field>
|
|
<field name="arch" type="xml">
|
|
<![CDATA[
|
|
<tree string="Parties">
|
|
<field name="code"/>
|
|
<field name="name"/>
|
|
<field name="lang"/>
|
|
<field name="vat_code"/>
|
|
<field name="active" tree_invisible="1"/>
|
|
<field name="vat_country" tree_invisible="1"/>
|
|
<field name="vat_number" tree_invisible="1"/>
|
|
</tree>
|
|
]]>
|
|
</field>
|
|
</record>
|
|
</data>
|
|
</tryton>
|
|
|
|
Here is the list of the tags:
|
|
|
|
* ``tryton``: The main tag of the xml
|
|
|
|
* ``data``: Define a set of data inside the file. It can have the
|
|
attributes ``noupdate`` to prevent the framework to update the records
|
|
and ``skiptest`` to prevent import of data when running tests.
|
|
|
|
* ``record``: Create a record of the model defined by the attribute
|
|
``model`` in the database. The ``id`` attribute can be used to refer to
|
|
the record later in any xml file.
|
|
|
|
* ``field``: Set the value of the field with the name defined by the
|
|
attribute ``name``.
|
|
|
|
Here is the list of attributes:
|
|
|
|
* ``search``: Only for relation field. It contains a domain which is
|
|
used to search for the value to use. The first value found will be
|
|
used.
|
|
|
|
* ``ref``: Only for relation field. It contains an xml id of the
|
|
relation to use as value. It must be prefixed by the module name with
|
|
an ending dot, if the record is defined in an other module.
|
|
|
|
* ``eval``: Python code to evaluate and use result as value.
|
|
|
|
* ``type``: If set to xml, it will use the CDATA content as value.
|
|
|
|
.. note::
|
|
Field content is considered as a string. So for fields that require
|
|
other types, it is required to use the ``eval`` attribute.
|
|
..
|
|
|
|
|
|
* ``menuitem``: Shortcut to create ir.ui.menu records.
|
|
|
|
Here is the list of attributes:
|
|
|
|
* ``id``: The id of the menu.
|
|
|
|
* ``name``: The name of the menu.
|
|
|
|
* ``icon``: The icon of the menu.
|
|
|
|
* ``sequence``: The sequence value used to order the menu entries.
|
|
|
|
* ``parent``: The xml id of the parent menu.
|
|
|
|
* ``action``: The xml id of the action linked to the menu.
|
|
|
|
* ``groups``: A list of xml id of group, that have access to the menu,
|
|
separated by commas.
|
|
|
|
* ``active``: A boolean telling if the menu is active or not.
|