~openerp-community/openobject-doc/ksa-openobject-doc-6.0

« back to all changes in this revision

Viewing changes to source/developer/5_16_data_serialization/xml_serialization.rst

  • Committer: Don Kirkby
  • Date: 2011-02-21 20:46:11 UTC
  • mfrom: (433.1.53 openobject-doc)
  • Revision ID: donkirkby+launpd@gmail.com-20110221204611-1ykt6dmg4k3gh5dh
[MERGE] revisions 477 to 486 from the 5.0 branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
Since version 4.2, OpenERP provides an XML-based data serialization format.
8
8
 
9
 
The basic format of an OpenERP XML file is as follows::
 
9
The basic format of an OpenERP XML file is as follows:
 
10
 
 
11
.. code-block:: xml
10
12
 
11
13
     <?xml version="1.0"?>
12
14
     <openerp>
13
15
         <data>
14
16
         <record model="model.name_1" id="id_name_1">
15
17
             <field name="field1">
16
 
                 %lightblue%"field1 content"
 
18
                 field1 content
17
19
             </field>
18
20
             <field name="field2">
19
 
                 %lightblue%"field2 content"
 
21
                 field2 content
20
22
             </field>
21
23
             (...)
22
24
         </record>
30
32
Fields contents are strings that must be encoded as UTF-8 in XML files.
31
33
 
32
34
Let's review an example taken from the OpenERP source (base_demo.xml in the base module):
33
 
::
 
35
 
 
36
.. code-block:: xml
34
37
 
35
38
       <record model="res.company" id="main_company">
36
39
           <field name="name">OpenERP SA</field>
38
41
           <field name="currency_id" ref="EUR"/>
39
42
       </record>
40
43
 
41
 
::
42
 
 
43
44
       <record model="res.users" id="user_admin">
44
45
           <field name="login">admin</field>
45
46
           <field name="password">admin</field>
57
58
    * The fields login, password, etc are straightforward.
58
59
    * The **ref** attribute allows to fill relations between the records :
59
60
 
60
 
::
 
61
.. code-block:: xml
61
62
 
62
63
    <field name="company_id" ref="main_company"/>
63
64
 
83
84
 
84
85
Example
85
86
~~~~~~~
86
 
::
 
87
 
 
88
.. code-block:: xml
87
89
 
88
90
    <record model="ir.actions.report.xml" id="l0">
89
91
         <field name="model">account.invoice</field>
115
117
 
116
118
Example
117
119
~~~~~~~
118
 
::
119
 
 
120
 
    <function model="ir.ui.menu" name="search" eval="[[('name','=','Operations')]]"/>
 
120
 
 
121
.. code-block:: xml
 
122
 
 
123
    <function 
 
124
        model="ir.ui.menu" 
 
125
        name="search" 
 
126
        eval="[[('name','=','Operations')]]"/>
121
127
 
122
128
getitem tag
123
129
+++++++++++
132
138
Example
133
139
~~~~~~~
134
140
 
135
 
Evaluates to the first element of the list of ids returned by the function node::
 
141
Evaluates to the first element of the list of ids returned by the function node:
 
142
 
 
143
.. code-block:: xml
136
144
 
137
145
    <getitem index="0" type="list">
138
 
        <function model="ir.ui.menu" name="search" eval="[[('name','=','Operations')]]"/>
 
146
        <function 
 
147
                model="ir.ui.menu" 
 
148
                name="search" 
 
149
                eval="[[('name','=','Operations')]]"/>
139
150
    </getitem>