~xrg/openobject-doc/trunk-xrg

« back to all changes in this revision

Viewing changes to i18n/uk/source/developer/3_11_reports/11_2_XSL-RML_reports.rst

  • Committer: TruongSinh Tran
  • Date: 2009-07-17 18:59:45 UTC
  • Revision ID: truongsinh@vipescoserver-20090717185945-ajjp3zso6xh5jddm
[FIX]private issue

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
.. i18n: XSL:RML reports
 
3
.. i18n: ===============
 
4
 
 
5
XSL:RML reports
 
6
===============
 
7
 
 
8
.. i18n: RML reports don't require programming but require two simple XML files to be written:
 
9
 
 
10
RML reports don't require programming but require two simple XML files to be written:
 
11
 
 
12
.. i18n:     * a file describing the data to export (\*.xml)
 
13
.. i18n:     * a file containing the presentation rules to apply to that data (\*.xsl)
 
14
 
 
15
    * a file describing the data to export (\*.xml)
 
16
    * a file containing the presentation rules to apply to that data (\*.xsl)
 
17
 
 
18
.. i18n: .. figure::  images/automatic-reports.png
 
19
.. i18n:    :scale: 85
 
20
.. i18n:    :align: center
 
21
 
 
22
.. figure::  images/automatic-reports.png
 
23
   :scale: 85
 
24
   :align: center
 
25
 
 
26
.. i18n: The role of the XML template is to describe which fields of the resource have to be exported (by the server). The XSL:RML style sheet deals with the layout of the exported data as well as the "static text" of reports. Static text is referring to the text which is common to all reports of the same type (for example, the title of table columns).
 
27
 
 
28
The role of the XML template is to describe which fields of the resource have to be exported (by the server). The XSL:RML style sheet deals with the layout of the exported data as well as the "static text" of reports. Static text is referring to the text which is common to all reports of the same type (for example, the title of table columns).
 
29
 
 
30
.. i18n: **Example**
 
31
 
 
32
**Example**
 
33
 
 
34
.. i18n: Here is, as an example, the different files for the simplest report in the ERP.
 
35
 
 
36
Here is, as an example, the different files for the simplest report in the ERP.
 
37
 
 
38
.. i18n: .. figure::  images/ids-report.png
 
39
.. i18n:    :scale: 85
 
40
.. i18n:    :align: center
 
41
 
 
42
.. figure::  images/ids-report.png
 
43
   :scale: 85
 
44
   :align: center
 
45
 
 
46
.. i18n: **XML Template**
 
47
.. i18n: ::
 
48
.. i18n: 
 
49
.. i18n:        <?xml version="1.0"?>
 
50
 
 
51
**XML Template**
 
52
::
 
53
 
 
54
        <?xml version="1.0"?>
 
55
 
 
56
.. i18n:            <ids> 
 
57
.. i18n:            <id type="fields" name="id">
 
58
 
 
59
            <ids> 
 
60
            <id type="fields" name="id">
 
61
 
 
62
.. i18n:                <name type="field" name="name"/> 
 
63
.. i18n:                <ref type="field" name="ref"/> 
 
64
 
 
65
                <name type="field" name="name"/> 
 
66
                <ref type="field" name="ref"/> 
 
67
 
 
68
.. i18n:            </id> 
 
69
.. i18n:            </ids> 
 
70
 
 
71
            </id> 
 
72
            </ids> 
 
73
 
 
74
.. i18n: **XML data file (generated)**
 
75
.. i18n: ::
 
76
.. i18n: 
 
77
.. i18n:        <?xml version="1.0"?>
 
78
 
 
79
**XML data file (generated)**
 
80
::
 
81
 
 
82
        <?xml version="1.0"?>
 
83
 
 
84
.. i18n:            <ids> 
 
85
.. i18n:            <id>
 
86
 
 
87
            <ids> 
 
88
            <id>
 
89
 
 
90
.. i18n:                <name>Tiny sprl</name> 
 
91
.. i18n:                <ref>pnk00</ref> 
 
92
 
 
93
                <name>Tiny sprl</name> 
 
94
                <ref>pnk00</ref> 
 
95
 
 
96
.. i18n:            </id><id>
 
97
 
 
98
            </id><id>
 
99
 
 
100
.. i18n:                <name>ASUS</name> 
 
101
.. i18n:                <ref></ref> 
 
102
 
 
103
                <name>ASUS</name> 
 
104
                <ref></ref> 
 
105
 
 
106
.. i18n:            </id><id>
 
107
 
 
108
            </id><id>
 
109
 
 
110
.. i18n:                <name>Agrolait</name> 
 
111
.. i18n:                <ref></ref> 
 
112
 
 
113
                <name>Agrolait</name> 
 
114
                <ref></ref> 
 
115
 
 
116
.. i18n:            </id><id>
 
117
 
 
118
            </id><id>
 
119
 
 
120
.. i18n:                <name>Banque Plein-Aux-As</name> 
 
121
.. i18n:                <ref></ref> 
 
122
 
 
123
                <name>Banque Plein-Aux-As</name> 
 
124
                <ref></ref> 
 
125
 
 
126
.. i18n:            </id><id>
 
127
 
 
128
            </id><id>
 
129
 
 
130
.. i18n:                <name>China Export</name> 
 
131
.. i18n:                <ref></ref> 
 
132
 
 
133
                <name>China Export</name> 
 
134
                <ref></ref> 
 
135
 
 
136
.. i18n:            </id><id>
 
137
 
 
138
            </id><id>
 
139
 
 
140
.. i18n:                <name>Ditrib PC</name> 
 
141
.. i18n:                <ref></ref> 
 
142
 
 
143
                <name>Ditrib PC</name> 
 
144
                <ref></ref> 
 
145
 
 
146
.. i18n:            </id><id>
 
147
 
 
148
            </id><id>
 
149
 
 
150
.. i18n:                <name>Ecole de Commerce de Liege</name> 
 
151
.. i18n:                <ref></ref> 
 
152
 
 
153
                <name>Ecole de Commerce de Liege</name> 
 
154
                <ref></ref> 
 
155
 
 
156
.. i18n:            </id><id>
 
157
 
 
158
            </id><id>
 
159
 
 
160
.. i18n:                <name>Elec Import</name> 
 
161
.. i18n:                <ref></ref> 
 
162
 
 
163
                <name>Elec Import</name> 
 
164
                <ref></ref> 
 
165
 
 
166
.. i18n:            </id><id>
 
167
 
 
168
            </id><id>
 
169
 
 
170
.. i18n:                <name>Maxtor</name> 
 
171
.. i18n:                <ref></ref> 
 
172
 
 
173
                <name>Maxtor</name> 
 
174
                <ref></ref> 
 
175
 
 
176
.. i18n:            </id><id>
 
177
 
 
178
            </id><id>
 
179
 
 
180
.. i18n:                <name>Mediapole SPRL</name> 
 
181
.. i18n:                <ref></ref> 
 
182
 
 
183
                <name>Mediapole SPRL</name> 
 
184
                <ref></ref> 
 
185
 
 
186
.. i18n:            </id><id>
 
187
 
 
188
            </id><id>
 
189
 
 
190
.. i18n:                <name>Opensides sprl</name> 
 
191
.. i18n:                <ref>os</ref> 
 
192
 
 
193
                <name>Opensides sprl</name> 
 
194
                <ref>os</ref> 
 
195
 
 
196
.. i18n:            </id><id>
 
197
 
 
198
            </id><id>
 
199
 
 
200
.. i18n:                <name>Tecsas sarl</name> 
 
201
.. i18n:                <ref></ref> 
 
202
 
 
203
                <name>Tecsas sarl</name> 
 
204
                <ref></ref> 
 
205
 
 
206
.. i18n:            </id> 
 
207
.. i18n:            </ids> 
 
208
 
 
209
            </id> 
 
210
            </ids> 
 
211
 
 
212
.. i18n: **XSL stylesheet**
 
213
.. i18n: ::
 
214
.. i18n: 
 
215
.. i18n:        <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
 
216
 
 
217
**XSL stylesheet**
 
218
::
 
219
 
 
220
        <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
 
221
 
 
222
.. i18n:            <xsl:template match="/">
 
223
 
 
224
            <xsl:template match="/">
 
225
 
 
226
.. i18n:                <xsl:apply-templates select="ids"/> 
 
227
 
 
228
                <xsl:apply-templates select="ids"/> 
 
229
 
 
230
.. i18n:            </xsl:template> 
 
231
 
 
232
            </xsl:template> 
 
233
 
 
234
.. i18n:            <xsl:template match="ids">
 
235
 
 
236
            <xsl:template match="ids">
 
237
 
 
238
.. i18n:                <document>
 
239
 
 
240
                <document>
 
241
 
 
242
.. i18n:                    <template pageSize="21cm,29.7cm">
 
243
 
 
244
                    <template pageSize="21cm,29.7cm">
 
245
 
 
246
.. i18n:                        <pageTemplate>
 
247
 
 
248
                        <pageTemplate>
 
249
 
 
250
.. i18n:                            <frame id="col1" x1="2cm" y1="2.4cm" width="8cm" height="26cm"/> 
 
251
.. i18n:                            <frame id="col2" x1="11cm" y1="2.4cm" width="8cm" height="26cm"/> 
 
252
 
 
253
                            <frame id="col1" x1="2cm" y1="2.4cm" width="8cm" height="26cm"/> 
 
254
                            <frame id="col2" x1="11cm" y1="2.4cm" width="8cm" height="26cm"/> 
 
255
 
 
256
.. i18n:                        </pageTemplate> 
 
257
 
 
258
                        </pageTemplate> 
 
259
 
 
260
.. i18n:                    </template> 
 
261
 
 
262
                    </template> 
 
263
 
 
264
.. i18n:                <stylesheet>
 
265
 
 
266
                <stylesheet>
 
267
 
 
268
.. i18n:                    <blockTableStyle id="ids"> 
 
269
 
 
270
                    <blockTableStyle id="ids"> 
 
271
 
 
272
.. i18n:                        <blockFont name="Helvetica-BoldOblique" size="12" start="0,0" stop="-1,0"/> 
 
273
.. i18n:                        <lineStyle kind="BOX" colorName="black" start="0,0" stop="-1,0"/> 
 
274
 
 
275
                        <blockFont name="Helvetica-BoldOblique" size="12" start="0,0" stop="-1,0"/> 
 
276
                        <lineStyle kind="BOX" colorName="black" start="0,0" stop="-1,0"/> 
 
277
 
 
278
.. i18n:                        <lineStyle kind="BOX" colorName="black" start="0,0" stop="-1,-1"/> 
 
279
 
 
280
                        <lineStyle kind="BOX" colorName="black" start="0,0" stop="-1,-1"/> 
 
281
 
 
282
.. i18n:                    </blockTableStyle> 
 
283
 
 
284
                    </blockTableStyle> 
 
285
 
 
286
.. i18n:                </stylesheet> 
 
287
 
 
288
                </stylesheet> 
 
289
 
 
290
.. i18n:                <story>
 
291
 
 
292
                <story>
 
293
 
 
294
.. i18n:                    <blockTable colWidths="2cm, 6cm" repeatRows="1" style="ids">
 
295
 
 
296
                    <blockTable colWidths="2cm, 6cm" repeatRows="1" style="ids">
 
297
 
 
298
.. i18n:                        <tr>
 
299
 
 
300
                        <tr>
 
301
 
 
302
.. i18n:                            <td t="1">Ref.</td> 
 
303
.. i18n:                            <td t="1">Name</td> 
 
304
 
 
305
                            <td t="1">Ref.</td> 
 
306
                            <td t="1">Name</td> 
 
307
 
 
308
.. i18n:                        </tr> 
 
309
.. i18n:                        <xsl:apply-templates select="id"/> 
 
310
 
 
311
                        </tr> 
 
312
                        <xsl:apply-templates select="id"/> 
 
313
 
 
314
.. i18n:                    </blockTable> 
 
315
 
 
316
                    </blockTable> 
 
317
 
 
318
.. i18n:                </story> 
 
319
.. i18n:                </document> 
 
320
 
 
321
                </story> 
 
322
                </document> 
 
323
 
 
324
.. i18n:            </xsl:template> 
 
325
 
 
326
            </xsl:template> 
 
327
 
 
328
.. i18n:            <xsl:template match="id">
 
329
 
 
330
            <xsl:template match="id">
 
331
 
 
332
.. i18n:                <tr>
 
333
 
 
334
                <tr>
 
335
 
 
336
.. i18n:                    <td><xsl:value-of select="ref"/></td> 
 
337
.. i18n:                    <td><para><xsl:value-of select="name"/></para></td> 
 
338
 
 
339
                    <td><xsl:value-of select="ref"/></td> 
 
340
                    <td><para><xsl:value-of select="name"/></para></td> 
 
341
 
 
342
.. i18n:                </tr> 
 
343
 
 
344
                </tr> 
 
345
 
 
346
.. i18n:            </xsl:template> 
 
347
.. i18n:            </xsl:stylesheet> 
 
348
 
 
349
            </xsl:template> 
 
350
            </xsl:stylesheet> 
 
351
 
 
352
.. i18n: **Resulting RML file (generated)**
 
353
.. i18n: ::
 
354
.. i18n: 
 
355
.. i18n:        <?xml version="1.0"?>
 
356
 
 
357
**Resulting RML file (generated)**
 
358
::
 
359
 
 
360
        <?xml version="1.0"?>
 
361
 
 
362
.. i18n:            <document> 
 
363
.. i18n:            ...
 
364
 
 
365
            <document> 
 
366
            ...
 
367
 
 
368
.. i18n:                <story>
 
369
 
 
370
                <story>
 
371
 
 
372
.. i18n:                    <blockTable colWidths="2cm, 6cm" repeatRows="1" style="ids">
 
373
 
 
374
                    <blockTable colWidths="2cm, 6cm" repeatRows="1" style="ids">
 
375
 
 
376
.. i18n:                        <tr>
 
377
 
 
378
                        <tr>
 
379
 
 
380
.. i18n:                            <td t="1">Ref.</td> 
 
381
.. i18n:                            <td t="1">Name</td> 
 
382
 
 
383
                            <td t="1">Ref.</td> 
 
384
                            <td t="1">Name</td> 
 
385
 
 
386
.. i18n:                        </tr> 
 
387
.. i18n:                        <tr>
 
388
 
 
389
                        </tr> 
 
390
                        <tr>
 
391
 
 
392
.. i18n:                            <td>pnk00</td> 
 
393
.. i18n:                            <td><para>Tiny sprl</para></td> 
 
394
 
 
395
                            <td>pnk00</td> 
 
396
                            <td><para>Tiny sprl</para></td> 
 
397
 
 
398
.. i18n:                        </tr> 
 
399
.. i18n:                        <tr>
 
400
 
 
401
                        </tr> 
 
402
                        <tr>
 
403
 
 
404
.. i18n:                            <td></td> 
 
405
.. i18n:                            <td><para>ASUS</para></td> 
 
406
 
 
407
                            <td></td> 
 
408
                            <td><para>ASUS</para></td> 
 
409
 
 
410
.. i18n:                        </tr> 
 
411
.. i18n:                        <tr>
 
412
 
 
413
                        </tr> 
 
414
                        <tr>
 
415
 
 
416
.. i18n:                            <td></td> 
 
417
.. i18n:                            <td><para>Agrolait</para></td> 
 
418
 
 
419
                            <td></td> 
 
420
                            <td><para>Agrolait</para></td> 
 
421
 
 
422
.. i18n:                        </tr> 
 
423
.. i18n:                        <tr>
 
424
 
 
425
                        </tr> 
 
426
                        <tr>
 
427
 
 
428
.. i18n:                            <td></td> 
 
429
.. i18n:                            <td><para>Banque Plein-Aux-As</para></td> 
 
430
 
 
431
                            <td></td> 
 
432
                            <td><para>Banque Plein-Aux-As</para></td> 
 
433
 
 
434
.. i18n:                        </tr> 
 
435
.. i18n:                        <tr>
 
436
 
 
437
                        </tr> 
 
438
                        <tr>
 
439
 
 
440
.. i18n:                            <td></td> 
 
441
.. i18n:                            <td><para>China Export</para></td> 
 
442
 
 
443
                            <td></td> 
 
444
                            <td><para>China Export</para></td> 
 
445
 
 
446
.. i18n:                        </tr> 
 
447
.. i18n:                        <tr>
 
448
 
 
449
                        </tr> 
 
450
                        <tr>
 
451
 
 
452
.. i18n:                            <td></td> 
 
453
.. i18n:                            <td><para>Ditrib PC</para></td> 
 
454
 
 
455
                            <td></td> 
 
456
                            <td><para>Ditrib PC</para></td> 
 
457
 
 
458
.. i18n:                        </tr> 
 
459
.. i18n:                        <tr>
 
460
 
 
461
                        </tr> 
 
462
                        <tr>
 
463
 
 
464
.. i18n:                            <td></td> 
 
465
.. i18n:                            <td><para>Ecole de Commerce de Liege</para></td> 
 
466
 
 
467
                            <td></td> 
 
468
                            <td><para>Ecole de Commerce de Liege</para></td> 
 
469
 
 
470
.. i18n:                        </tr> 
 
471
.. i18n:                        <tr>
 
472
 
 
473
                        </tr> 
 
474
                        <tr>
 
475
 
 
476
.. i18n:                            <td></td> 
 
477
.. i18n:                            <td><para>Elec Import</para></td> 
 
478
 
 
479
                            <td></td> 
 
480
                            <td><para>Elec Import</para></td> 
 
481
 
 
482
.. i18n:                        </tr> 
 
483
.. i18n:                        <tr>
 
484
 
 
485
                        </tr> 
 
486
                        <tr>
 
487
 
 
488
.. i18n:                            <td></td> 
 
489
.. i18n:                            <td><para>Maxtor</para></td> 
 
490
 
 
491
                            <td></td> 
 
492
                            <td><para>Maxtor</para></td> 
 
493
 
 
494
.. i18n:                        </tr> 
 
495
.. i18n:                        <tr>
 
496
 
 
497
                        </tr> 
 
498
                        <tr>
 
499
 
 
500
.. i18n:                            <td></td> 
 
501
.. i18n:                            <td><para>Mediapole SPRL</para></td> 
 
502
 
 
503
                            <td></td> 
 
504
                            <td><para>Mediapole SPRL</para></td> 
 
505
 
 
506
.. i18n:                        </tr> 
 
507
.. i18n:                        <tr>
 
508
 
 
509
                        </tr> 
 
510
                        <tr>
 
511
 
 
512
.. i18n:                            <td>os</td> 
 
513
.. i18n:                            <td><para>Opensides sprl</para></td> 
 
514
 
 
515
                            <td>os</td> 
 
516
                            <td><para>Opensides sprl</para></td> 
 
517
 
 
518
.. i18n:                        </tr> 
 
519
.. i18n:                        <tr> 
 
520
.. i18n:                        <td></td>
 
521
 
 
522
                        </tr> 
 
523
                        <tr> 
 
524
                        <td></td>
 
525
 
 
526
.. i18n:                            <td><para>Tecsas sarl</para></td> 
 
527
 
 
528
                            <td><para>Tecsas sarl</para></td> 
 
529
 
 
530
.. i18n:                        </tr> 
 
531
 
 
532
                        </tr> 
 
533
 
 
534
.. i18n:                    </blockTable> 
 
535
 
 
536
                    </blockTable> 
 
537
 
 
538
.. i18n:                </story> 
 
539
 
 
540
                </story> 
 
541
 
 
542
.. i18n:            </document> 
 
543
 
 
544
            </document> 
 
545
 
 
546
.. i18n: Fore more information on the formats used:
 
547
 
 
548
Fore more information on the formats used:
 
549
 
 
550
.. i18n:     * RML : http://reportlab.com/docs/RML_UserGuide_1_0.pdf
 
551
.. i18n:     * XSL - Specification : http://www.w3.org/TR/xslt
 
552
.. i18n:     * XSL - Tutorial : http://www.zvon.org/xxl/XSLTutorial/Books/Output/contents.html 
 
553
 
 
554
    * RML : http://reportlab.com/docs/RML_UserGuide_1_0.pdf
 
555
    * XSL - Specification : http://www.w3.org/TR/xslt
 
556
    * XSL - Tutorial : http://www.zvon.org/xxl/XSLTutorial/Books/Output/contents.html 
 
557
 
 
558
.. i18n: All these formats use XML:
 
559
 
 
560
All these formats use XML:
 
561
 
 
562
.. i18n:     * http://www.w3.org/XML/ 
 
563
 
 
564
    * http://www.w3.org/XML/ 
 
565
 
 
566
.. i18n: XML Template
 
567
.. i18n: ------------
 
568
 
 
569
XML Template
 
570
------------
 
571
 
 
572
.. i18n: XML templates are simple XML files describing which fields among all available object fields are necessary for the report.
 
573
 
 
574
XML templates are simple XML files describing which fields among all available object fields are necessary for the report.
 
575
 
 
576
.. i18n: File format
 
577
.. i18n: """""""""""
 
578
 
 
579
File format
 
580
"""""""""""
 
581
 
 
582
.. i18n: Tag names can be chosen arbitrarily (it must be valid XML though). In the XSL file, you will have to use those names. Most of the time, the name of a tag will be the same as the name of the object field it refers to.
 
583
 
 
584
Tag names can be chosen arbitrarily (it must be valid XML though). In the XSL file, you will have to use those names. Most of the time, the name of a tag will be the same as the name of the object field it refers to.
 
585
 
 
586
.. i18n: Nodes without **type** attribute are transferred identically into the XML destination file (the data file). Nodes with a type attribute will be parsed by the server and their content will be replaced by data coming from objects. In addition to the type attribute, nodes have other possible attributes. These attributes depend on the type of the node (each node type supports or needs different attributes). Most node types have a name attribute, which refers to the  **name** of a field of the object on which we work.
 
587
 
 
588
Nodes without **type** attribute are transferred identically into the XML destination file (the data file). Nodes with a type attribute will be parsed by the server and their content will be replaced by data coming from objects. In addition to the type attribute, nodes have other possible attributes. These attributes depend on the type of the node (each node type supports or needs different attributes). Most node types have a name attribute, which refers to the  **name** of a field of the object on which we work.
 
589
 
 
590
.. i18n: As for the "browse" method on objects, field names in reports can use a notation similar to the notation found in object oriented programming languages. It means that "relation fields" can be used as "bridges" to fetch data from other (related) objects.
 
591
 
 
592
As for the "browse" method on objects, field names in reports can use a notation similar to the notation found in object oriented programming languages. It means that "relation fields" can be used as "bridges" to fetch data from other (related) objects.
 
593
 
 
594
.. i18n: Let's use the "account.transfer" object as an example. It contains a partner_id field. This field is a relation field ("many to one") pointing to the "res.partner" object. Let's suppose that we want to create a report for transfers and in this report, we want to use the name of the recipient partner. This name could be accessed using the following expression as the name of the field:
 
595
 
 
596
Let's use the "account.transfer" object as an example. It contains a partner_id field. This field is a relation field ("many to one") pointing to the "res.partner" object. Let's suppose that we want to create a report for transfers and in this report, we want to use the name of the recipient partner. This name could be accessed using the following expression as the name of the field:
 
597
 
 
598
.. i18n:     partner_id.name 
 
599
 
 
600
    partner_id.name 
 
601
 
 
602
.. i18n: Possible types
 
603
.. i18n: """"""""""""""
 
604
 
 
605
Possible types
 
606
""""""""""""""
 
607
 
 
608
.. i18n: Here is the list of available field types:
 
609
 
 
610
Here is the list of available field types:
 
611
 
 
612
.. i18n:     * **field**: It is the simplest type. For nodes of this type, the server replaces the node content by the value of the field whose name is given in the name attribute. 
 
613
.. i18n: 
 
614
.. i18n:     * **fields**: when this type of node is used, the server will generate a node in the XML data file for each unique value of the field whose name is given in the name attribute. 
 
615
 
 
616
    * **field**: It is the simplest type. For nodes of this type, the server replaces the node content by the value of the field whose name is given in the name attribute. 
 
617
 
 
618
    * **fields**: when this type of node is used, the server will generate a node in the XML data file for each unique value of the field whose name is given in the name attribute. 
 
619
 
 
620
.. i18n:     Notes:
 
621
 
 
622
    Notes:
 
623
 
 
624
.. i18n:         ** This node type is often used with "id" as its name attribute. This has the effect of creating one node for each resource selected in the interface by the user. 
 
625
.. i18n:         ** The semantics of a node <node type="fields" name="field_name"> is similar to an SQL statement of the form "SELECT FROM object_table WHERE id in identifier_list **GROUP BY** field_name" where identifier_list is the list of ids of the resources selected by the ::user (in the interface). 
 
626
 
 
627
        ** This node type is often used with "id" as its name attribute. This has the effect of creating one node for each resource selected in the interface by the user. 
 
628
        ** The semantics of a node <node type="fields" name="field_name"> is similar to an SQL statement of the form "SELECT FROM object_table WHERE id in identifier_list **GROUP BY** field_name" where identifier_list is the list of ids of the resources selected by the ::user (in the interface). 
 
629
 
 
630
.. i18n:     * **eval**: This node type evaluate the expression given in the *expr* attribute. This expression may be any Python expression and may contain objects fields names. 
 
631
.. i18n: 
 
632
.. i18n:     * **zoom**: This node type allows to "enter" into the resource referenced by the relation field whose name is given in the name attribute. It means that its child nodes will be able to access the fields of that resource without having to prefix them with the field name that makes the link with the other object. In our example above, we could also have accessed the field name of the partner with the following: 
 
633
 
 
634
    * **eval**: This node type evaluate the expression given in the *expr* attribute. This expression may be any Python expression and may contain objects fields names. 
 
635
 
 
636
    * **zoom**: This node type allows to "enter" into the resource referenced by the relation field whose name is given in the name attribute. It means that its child nodes will be able to access the fields of that resource without having to prefix them with the field name that makes the link with the other object. In our example above, we could also have accessed the field name of the partner with the following: 
 
637
 
 
638
.. i18n:   ::
 
639
.. i18n: 
 
640
.. i18n:        <partner type="zoom" name="partner_id">
 
641
 
 
642
  ::
 
643
 
 
644
        <partner type="zoom" name="partner_id">
 
645
 
 
646
.. i18n:                <name type="field" name="name"/> 
 
647
 
 
648
                <name type="field" name="name"/> 
 
649
 
 
650
.. i18n:        </partner> 
 
651
 
 
652
        </partner> 
 
653
 
 
654
.. i18n:        In this precise case, there is of course no point in using this notation instead of the standard notation below: 
 
655
 
 
656
        In this precise case, there is of course no point in using this notation instead of the standard notation below: 
 
657
 
 
658
.. i18n:        <name type="field" name="partner_id.name"/> 
 
659
 
 
660
        <name type="field" name="partner_id.name"/> 
 
661
 
 
662
.. i18n: The **zoom** type is only useful when we want to recover several fields in the same object.
 
663
 
 
664
The **zoom** type is only useful when we want to recover several fields in the same object.
 
665
 
 
666
.. i18n:     * **function**: returns the result of the call to the function whose name is given in the name attribute. This function must be part of the list of predefined functions. For the moment, the only available function is today, which returns the current date. 
 
667
.. i18n: 
 
668
.. i18n:     * **call**: calls the object method whose name is given in the name attribute with the arguments given in the args attribute. The result is stored into a dictionary of the form {'name_of_variable': value, ... } and can be accessed through child nodes. These nodes must have a value attribute which correspond to one of the keys of the dictionary returned by the method. 
 
669
 
 
670
    * **function**: returns the result of the call to the function whose name is given in the name attribute. This function must be part of the list of predefined functions. For the moment, the only available function is today, which returns the current date. 
 
671
 
 
672
    * **call**: calls the object method whose name is given in the name attribute with the arguments given in the args attribute. The result is stored into a dictionary of the form {'name_of_variable': value, ... } and can be accessed through child nodes. These nodes must have a value attribute which correspond to one of the keys of the dictionary returned by the method. 
 
673
 
 
674
.. i18n: **Example**:
 
675
.. i18n: ::
 
676
.. i18n: 
 
677
.. i18n:        <cost type="call" name="compute_seller_costs" args="">
 
678
 
 
679
**Example**:
 
680
::
 
681
 
 
682
        <cost type="call" name="compute_seller_costs" args="">
 
683
 
 
684
.. i18n:            <name value="name"/> 
 
685
.. i18n:            <amount value="amount"/> 
 
686
 
 
687
            <name value="name"/> 
 
688
            <amount value="amount"/> 
 
689
 
 
690
.. i18n:        </cost> 
 
691
 
 
692
        </cost> 
 
693
 
 
694
.. i18n: **TODO**: documenter format methode appellée def compute_buyer_costs(self, cr, uid, ids, \*args):
 
695
 
 
696
**TODO**: documenter format methode appellée def compute_buyer_costs(self, cr, uid, ids, \*args):
 
697
 
 
698
.. i18n:     * **attachment**: extract the first attachment of the resource whose id is taken from the field whose name is given in the name attribute, and put it as an image in the report. 
 
699
 
 
700
    * **attachment**: extract the first attachment of the resource whose id is taken from the field whose name is given in the name attribute, and put it as an image in the report. 
 
701
 
 
702
.. i18n: Example:
 
703
.. i18n:        <image type="attachment" name="id"/> 
 
704
 
 
705
Example:
 
706
        <image type="attachment" name="id"/> 
 
707
 
 
708
.. i18n: **Example**
 
709
 
 
710
**Example**
 
711
 
 
712
.. i18n: Here is an example of XML file:
 
713
.. i18n: ::
 
714
.. i18n: 
 
715
.. i18n:            <?xml version="1.0" encoding="ISO-8859-1"?> 
 
716
.. i18n:            <transfer-list>
 
717
 
 
718
Here is an example of XML file:
 
719
::
 
720
 
 
721
            <?xml version="1.0" encoding="ISO-8859-1"?> 
 
722
            <transfer-list>
 
723
 
 
724
.. i18n:                <transfer type="fields" name="id">
 
725
 
 
726
                <transfer type="fields" name="id">
 
727
 
 
728
.. i18n:                    <name type="field" name="name"/> 
 
729
.. i18n:                    <partner_id type="field" name="partner_id.name"/> 
 
730
.. i18n:                    <date type="field" name="date"/> 
 
731
.. i18n:                    <type type="field" name="type"/> 
 
732
.. i18n:                    <reference type="field" name="reference"/> 
 
733
.. i18n:                    <amount type="field" name="amount"/> 
 
734
.. i18n:                    <change type="field" name="change"/> 
 
735
 
 
736
                    <name type="field" name="name"/> 
 
737
                    <partner_id type="field" name="partner_id.name"/> 
 
738
                    <date type="field" name="date"/> 
 
739
                    <type type="field" name="type"/> 
 
740
                    <reference type="field" name="reference"/> 
 
741
                    <amount type="field" name="amount"/> 
 
742
                    <change type="field" name="change"/> 
 
743
 
 
744
.. i18n:                </transfer> 
 
745
 
 
746
                </transfer> 
 
747
 
 
748
.. i18n:            </transfer-list> 
 
749
 
 
750
            </transfer-list> 
 
751
 
 
752
.. i18n: Introduction to RML
 
753
.. i18n: -------------------
 
754
 
 
755
Introduction to RML
 
756
-------------------
 
757
 
 
758
.. i18n: For more information on the RML format, please refer to the official Reportlab documentation.
 
759
 
 
760
For more information on the RML format, please refer to the official Reportlab documentation.
 
761
 
 
762
.. i18n:     * http://www.reportlab.com/docs/RML_UserGuide.pdf 
 
763
 
 
764
    * http://www.reportlab.com/docs/RML_UserGuide.pdf 
 
765
 
 
766
.. i18n: XSL:RML Stylesheet
 
767
.. i18n: ------------------
 
768
 
 
769
XSL:RML Stylesheet
 
770
------------------
 
771
 
 
772
.. i18n: There are two possibilities to do a XSL style sheet for a report. Either making everything by yourself, or use our predefined templates
 
773
 
 
774
There are two possibilities to do a XSL style sheet for a report. Either making everything by yourself, or use our predefined templates
 
775
 
 
776
.. i18n: Either freestyle or use corporate_defaults + rml_template
 
777
 
 
778
Either freestyle or use corporate_defaults + rml_template
 
779
 
 
780
.. i18n:     import rml_template.xsl 
 
781
 
 
782
    import rml_template.xsl 
 
783
 
 
784
.. i18n:         required templates:
 
785
 
 
786
        required templates:
 
787
 
 
788
.. i18n:             - frames? 
 
789
.. i18n:             - stylesheet 
 
790
.. i18n:             - story 
 
791
 
 
792
            - frames? 
 
793
            - stylesheet 
 
794
            - story 
 
795
 
 
796
.. i18n:         optional templates: 
 
797
 
 
798
        optional templates: 
 
799
 
 
800
.. i18n: Translations
 
801
.. i18n: """"""""""""
 
802
 
 
803
Translations
 
804
""""""""""""
 
805
 
 
806
.. i18n: As Open ERP can be used in several langages, reports must be translatable. But in a report, everything doesn't have to be translated : only the actual text has to be translated, not the formatting codes. A field will be processed by the translation system if the XML tag which surrounds it (whatever it is) has a t="1" attribute. The server will translate all the fields with such attributes in the report generation process.
 
807
 
 
808
As Open ERP can be used in several langages, reports must be translatable. But in a report, everything doesn't have to be translated : only the actual text has to be translated, not the formatting codes. A field will be processed by the translation system if the XML tag which surrounds it (whatever it is) has a t="1" attribute. The server will translate all the fields with such attributes in the report generation process.
 
809
 
 
810
.. i18n: Useful links:
 
811
.. i18n: """""""""""""
 
812
 
 
813
Useful links:
 
814
"""""""""""""
 
815
 
 
816
.. i18n:     * http://www.reportlab.com/docs/RML_UserGuide.pdf RML UserGuide (pdf) (reportlab.com) 
 
817
.. i18n: 
 
818
.. i18n:     * http://www.zvon.org/xxl/XSLTutorial/Output/index.html XSL Tutorial (zvon.org)
 
819
.. i18n:     * http://www.zvon.org/xxl/XSLTreference/Output/index.html XSL Reference (zvon.org)
 
820
.. i18n:     * http://www.w3schools.com/xsl/ XSL tutorial and references (W3Schools)
 
821
.. i18n:     * http://www.w3.org/TR/xslt/ XSL Specification (W3C) 
 
822
 
 
823
    * http://www.reportlab.com/docs/RML_UserGuide.pdf RML UserGuide (pdf) (reportlab.com) 
 
824
 
 
825
    * http://www.zvon.org/xxl/XSLTutorial/Output/index.html XSL Tutorial (zvon.org)
 
826
    * http://www.zvon.org/xxl/XSLTreference/Output/index.html XSL Reference (zvon.org)
 
827
    * http://www.w3schools.com/xsl/ XSL tutorial and references (W3Schools)
 
828
    * http://www.w3.org/TR/xslt/ XSL Specification (W3C) 
 
829
 
 
830
.. i18n: Example (with corporate defaults):
 
831
.. i18n: """""""""""""""""""""""""""""""""""
 
832
.. i18n: ::
 
833
.. i18n: 
 
834
.. i18n:            <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" :xmlns:fo="http://www.w3.org/1999/XSL/Format">
 
835
 
 
836
Example (with corporate defaults):
 
837
"""""""""""""""""""""""""""""""""""
 
838
::
 
839
 
 
840
            <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" :xmlns:fo="http://www.w3.org/1999/XSL/Format">
 
841
 
 
842
.. i18n:                <xsl:import href="../../custom/corporate_defaults.xsl"/> 
 
843
.. i18n:                <xsl:import href="../../base/report/rml_template.xsl"/> 
 
844
.. i18n:                <xsl:variable name="page_format">a4_normal</xsl:variable> 
 
845
.. i18n:                <xsl:template match="/">
 
846
 
 
847
                <xsl:import href="../../custom/corporate_defaults.xsl"/> 
 
848
                <xsl:import href="../../base/report/rml_template.xsl"/> 
 
849
                <xsl:variable name="page_format">a4_normal</xsl:variable> 
 
850
                <xsl:template match="/">
 
851
 
 
852
.. i18n:                    <xsl:call-template name="rml"/> 
 
853
 
 
854
                    <xsl:call-template name="rml"/> 
 
855
 
 
856
.. i18n:                </xsl:template> 
 
857
.. i18n:                <xsl:template name="stylesheet">
 
858
 
 
859
                </xsl:template> 
 
860
                <xsl:template name="stylesheet">
 
861
 
 
862
.. i18n:                    </xsl:template> 
 
863
 
 
864
                    </xsl:template> 
 
865
 
 
866
.. i18n:                <xsl:template name="story">
 
867
 
 
868
                <xsl:template name="story">
 
869
 
 
870
.. i18n:                    <xsl:apply-templates select="transfer-list"/> 
 
871
 
 
872
                    <xsl:apply-templates select="transfer-list"/> 
 
873
 
 
874
.. i18n:                </xsl:template> 
 
875
.. i18n:                <xsl:template match="transfer-list">
 
876
 
 
877
                </xsl:template> 
 
878
                <xsl:template match="transfer-list">
 
879
 
 
880
.. i18n:                    <xsl:apply-templates select="transfer"/> 
 
881
 
 
882
                    <xsl:apply-templates select="transfer"/> 
 
883
 
 
884
.. i18n:                </xsl:template> 
 
885
.. i18n:                <xsl:template match="transfer">
 
886
 
 
887
                </xsl:template> 
 
888
                <xsl:template match="transfer">
 
889
 
 
890
.. i18n:                    <setNextTemplate name="other_pages"/> 
 
891
.. i18n:                    <para>
 
892
 
 
893
                    <setNextTemplate name="other_pages"/> 
 
894
                    <para>
 
895
 
 
896
.. i18n:                        Document: <xsl:value-of select="name"/> 
 
897
 
 
898
                        Document: <xsl:value-of select="name"/> 
 
899
 
 
900
.. i18n:                    </para><para>
 
901
 
 
902
                    </para><para>
 
903
 
 
904
.. i18n:                        Type: <xsl:value-of select="type"/> 
 
905
 
 
906
                        Type: <xsl:value-of select="type"/> 
 
907
 
 
908
.. i18n:                    </para><para>
 
909
 
 
910
                    </para><para>
 
911
 
 
912
.. i18n:                        Reference: <xsl:value-of select="reference"/> 
 
913
 
 
914
                        Reference: <xsl:value-of select="reference"/> 
 
915
 
 
916
.. i18n:                    </para><para>
 
917
 
 
918
                    </para><para>
 
919
 
 
920
.. i18n:                        Partner ID: <xsl:value-of select="partner_id"/> 
 
921
 
 
922
                        Partner ID: <xsl:value-of select="partner_id"/> 
 
923
 
 
924
.. i18n:                    </para><para>
 
925
 
 
926
                    </para><para>
 
927
 
 
928
.. i18n:                        Date: <xsl:value-of select="date"/> 
 
929
 
 
930
                        Date: <xsl:value-of select="date"/> 
 
931
 
 
932
.. i18n:                    </para><para>
 
933
 
 
934
                    </para><para>
 
935
 
 
936
.. i18n:                        Amount: <xsl:value-of select="amount"/> 
 
937
 
 
938
                        Amount: <xsl:value-of select="amount"/> 
 
939
 
 
940
.. i18n:                    </para> 
 
941
.. i18n:                    <xsl:if test="number(change)>0">
 
942
 
 
943
                    </para> 
 
944
                    <xsl:if test="number(change)>0">
 
945
 
 
946
.. i18n:                        <para>
 
947
 
 
948
                        <para>
 
949
 
 
950
.. i18n:                            Change: <xsl:value-of select="change"/> 
 
951
 
 
952
                            Change: <xsl:value-of select="change"/> 
 
953
 
 
954
.. i18n:                        </para> 
 
955
 
 
956
                        </para> 
 
957
 
 
958
.. i18n:                    </xsl:if> 
 
959
.. i18n:                    <setNextTemplate name="first_page"/> 
 
960
.. i18n:                    <pageBreak/> 
 
961
 
 
962
                    </xsl:if> 
 
963
                    <setNextTemplate name="first_page"/> 
 
964
                    <pageBreak/> 
 
965
 
 
966
.. i18n:                </xsl:template> 
 
967
 
 
968
                </xsl:template> 
 
969
 
 
970
.. i18n:            </xsl:stylesheet> 
 
971
 
 
972
            </xsl:stylesheet> 
 
973
 
 
974
.. i18n: Reports without corporate header 
 
975
.. i18n: ================================
 
976
 
 
977
Reports without corporate header 
 
978
================================
 
979
 
 
980
.. i18n: **Example (with corporate defaults):**
 
981
.. i18n: ::
 
982
.. i18n: 
 
983
.. i18n:        <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" :xmlns:fo="http://www.w3.org/1999/XSL/Format">
 
984
.. i18n:             <xsl:import href="../../base/report/rml_template.xsl"/>
 
985
.. i18n:             <xsl:variable name="page_format">a4_normal</xsl:variable>
 
986
.. i18n:         
 
987
.. i18n:             <xsl:template match="/">
 
988
.. i18n:                  <xsl:call-template name="rml"/>
 
989
.. i18n:             </xsl:template>
 
990
.. i18n:         
 
991
.. i18n:             <xsl:template name="stylesheet">
 
992
.. i18n:              </xsl:template>
 
993
.. i18n:          
 
994
.. i18n:              <xsl:template name="story">
 
995
.. i18n:                   <xsl:apply-templates select="transfer-list"/>
 
996
.. i18n:              </xsl:template>
 
997
.. i18n:          
 
998
.. i18n:              <xsl:template match="transfer-list">
 
999
.. i18n:                   <xsl:apply-templates select="transfer"/>
 
1000
.. i18n:              </xsl:template>
 
1001
.. i18n:          
 
1002
.. i18n:              <xsl:template match="transfer">
 
1003
.. i18n:                   <setNextTemplate name="other_pages"/>
 
1004
.. i18n:           
 
1005
.. i18n:                   <para>
 
1006
.. i18n:                         Document: <xsl:value-of select="name"/>
 
1007
.. i18n:                   </para><para>
 
1008
.. i18n:                         Type: <xsl:value-of select="type"/>
 
1009
.. i18n:                   </para><para>
 
1010
.. i18n:                         Reference: <xsl:value-of select="reference"/>
 
1011
.. i18n:                   </para><para>
 
1012
.. i18n:                         Partner ID: <xsl:value-of select="partner_id"/>
 
1013
.. i18n:                   </para><para>
 
1014
.. i18n:                         Date: <xsl:value-of select="date"/>
 
1015
.. i18n:                   </para><para>
 
1016
.. i18n:                         Amount: <xsl:value-of select="amount"/>
 
1017
.. i18n:                   </para>
 
1018
.. i18n:           
 
1019
.. i18n:                   <xsl:if test="number(change)>0">
 
1020
.. i18n:                        <para>
 
1021
.. i18n:                              Change: <xsl:value-of select="change"/>
 
1022
.. i18n:                        </para>
 
1023
.. i18n:                   </xsl:if>
 
1024
.. i18n:           
 
1025
.. i18n:                   <setNextTemplate name="first_page"/> 
 
1026
.. i18n:                  <pageBreak/>
 
1027
.. i18n:             </xsl:template>
 
1028
.. i18n:        </xsl:stylesheet>
 
1029
 
 
1030
**Example (with corporate defaults):**
 
1031
::
 
1032
 
 
1033
        <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" :xmlns:fo="http://www.w3.org/1999/XSL/Format">
 
1034
             <xsl:import href="../../base/report/rml_template.xsl"/>
 
1035
             <xsl:variable name="page_format">a4_normal</xsl:variable>
 
1036
         
 
1037
             <xsl:template match="/">
 
1038
                  <xsl:call-template name="rml"/>
 
1039
             </xsl:template>
 
1040
         
 
1041
             <xsl:template name="stylesheet">
 
1042
              </xsl:template>
 
1043
          
 
1044
              <xsl:template name="story">
 
1045
                   <xsl:apply-templates select="transfer-list"/>
 
1046
              </xsl:template>
 
1047
          
 
1048
              <xsl:template match="transfer-list">
 
1049
                   <xsl:apply-templates select="transfer"/>
 
1050
              </xsl:template>
 
1051
          
 
1052
              <xsl:template match="transfer">
 
1053
                   <setNextTemplate name="other_pages"/>
 
1054
           
 
1055
                   <para>
 
1056
                         Document: <xsl:value-of select="name"/>
 
1057
                   </para><para>
 
1058
                         Type: <xsl:value-of select="type"/>
 
1059
                   </para><para>
 
1060
                         Reference: <xsl:value-of select="reference"/>
 
1061
                   </para><para>
 
1062
                         Partner ID: <xsl:value-of select="partner_id"/>
 
1063
                   </para><para>
 
1064
                         Date: <xsl:value-of select="date"/>
 
1065
                   </para><para>
 
1066
                         Amount: <xsl:value-of select="amount"/>
 
1067
                   </para>
 
1068
           
 
1069
                   <xsl:if test="number(change)>0">
 
1070
                        <para>
 
1071
                              Change: <xsl:value-of select="change"/>
 
1072
                        </para>
 
1073
                   </xsl:if>
 
1074
           
 
1075
                   <setNextTemplate name="first_page"/> 
 
1076
                  <pageBreak/>
 
1077
             </xsl:template>
 
1078
        </xsl:stylesheet>
 
1079
 
 
1080
.. i18n: Each report with its own corporate header 
 
1081
.. i18n: =========================================
 
1082
 
 
1083
Each report with its own corporate header 
 
1084
=========================================
 
1085
 
 
1086
.. i18n: **Example (with corporate defaults):**
 
1087
.. i18n: ::
 
1088
.. i18n: 
 
1089
.. i18n:            <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" :xmlns:fo="http://www.w3.org/1999/XSL/Format">
 
1090
 
 
1091
**Example (with corporate defaults):**
 
1092
::
 
1093
 
 
1094
            <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" :xmlns:fo="http://www.w3.org/1999/XSL/Format">
 
1095
 
 
1096
.. i18n:                <xsl:import href="../../custom/corporate_defaults.xsl"/> 
 
1097
.. i18n:                <xsl:import href="../../base/report/rml_template.xsl"/> 
 
1098
.. i18n:                <xsl:variable name="page_format">a4_normal</xsl:variable> 
 
1099
.. i18n:                ..................... 
 
1100
.. i18n:                </xsl:template> 
 
1101
 
 
1102
                <xsl:import href="../../custom/corporate_defaults.xsl"/> 
 
1103
                <xsl:import href="../../base/report/rml_template.xsl"/> 
 
1104
                <xsl:variable name="page_format">a4_normal</xsl:variable> 
 
1105
                ..................... 
 
1106
                </xsl:template> 
 
1107
 
 
1108
.. i18n:            </xsl:stylesheet> 
 
1109
 
 
1110
            </xsl:stylesheet> 
 
1111
 
 
1112
.. i18n: Bar Codes 
 
1113
.. i18n: =========
 
1114
 
 
1115
Bar Codes 
 
1116
=========
 
1117
 
 
1118
.. i18n: Barcodes in RML files
 
1119
.. i18n: ---------------------
 
1120
 
 
1121
Barcodes in RML files
 
1122
---------------------
 
1123
 
 
1124
.. i18n: Barcodes can be generated using the <barcode> tag in RML files. The following formats are supported:
 
1125
 
 
1126
Barcodes can be generated using the <barcode> tag in RML files. The following formats are supported:
 
1127
 
 
1128
.. i18n:     * codabar
 
1129
.. i18n:     * code11
 
1130
.. i18n:     * code128 (default if no 'code' specified')
 
1131
.. i18n:     * standard39
 
1132
.. i18n:     * standard93
 
1133
.. i18n:     * i2of5
 
1134
.. i18n:     * extended39
 
1135
.. i18n:     * extended93
 
1136
.. i18n:     * msi
 
1137
.. i18n:     * fim
 
1138
.. i18n:     * postnet 
 
1139
 
 
1140
    * codabar
 
1141
    * code11
 
1142
    * code128 (default if no 'code' specified')
 
1143
    * standard39
 
1144
    * standard93
 
1145
    * i2of5
 
1146
    * extended39
 
1147
    * extended93
 
1148
    * msi
 
1149
    * fim
 
1150
    * postnet 
 
1151
 
 
1152
.. i18n: You can change the following attributes for rendering your barcode:
 
1153
 
 
1154
You can change the following attributes for rendering your barcode:
 
1155
 
 
1156
.. i18n:     * 'code': 'char'
 
1157
.. i18n:     * 'ratio':'float'
 
1158
.. i18n:     * 'xdim':'unit'
 
1159
.. i18n:     * 'height':'unit'
 
1160
.. i18n:     * 'checksum':'bool'
 
1161
.. i18n:     * 'quiet':'bool' 
 
1162
 
 
1163
    * 'code': 'char'
 
1164
    * 'ratio':'float'
 
1165
    * 'xdim':'unit'
 
1166
    * 'height':'unit'
 
1167
    * 'checksum':'bool'
 
1168
    * 'quiet':'bool' 
 
1169
 
 
1170
.. i18n: Examples:
 
1171
 
 
1172
Examples:
 
1173
 
 
1174
.. i18n:     <barcode code="code128" xdim="28cm" ratio="2.2">`SN12345678</barcode> 
 
1175
 
 
1176
    <barcode code="code128" xdim="28cm" ratio="2.2">`SN12345678</barcode> 
 
1177
 
 
1178
.. i18n: How to add a new report
 
1179
.. i18n: =======================
 
1180
 
 
1181
How to add a new report
 
1182
=======================
 
1183
 
 
1184
.. i18n: In 4.0.X
 
1185
 
 
1186
In 4.0.X
 
1187
 
 
1188
.. i18n:     Administration -> Custom -> Low Level -> Base->Actions -> ir.actions.report.xml 
 
1189
 
 
1190
    Administration -> Custom -> Low Level -> Base->Actions -> ir.actions.report.xml 
 
1191
 
 
1192
.. i18n: Usual TAGS
 
1193
.. i18n: ==========
 
1194
 
 
1195
Usual TAGS
 
1196
==========
 
1197
 
 
1198
.. i18n: Code find in [[ ]] tags is python code.
 
1199
.. i18n: ---------------------------------------
 
1200
 
 
1201
Code find in [[ ]] tags is python code.
 
1202
---------------------------------------
 
1203
 
 
1204
.. i18n: The context of the code (the variable's values you can use) is the following:
 
1205
 
 
1206
The context of the code (the variable's values you can use) is the following:
 
1207
 
 
1208
.. i18n: python objects/variables, available when the report start:
 
1209
 
 
1210
python objects/variables, available when the report start:
 
1211
 
 
1212
.. i18n: "objects" the list of objects to be printed (invoices for example)
 
1213
 
 
1214
"objects" the list of objects to be printed (invoices for example)
 
1215
 
 
1216
.. i18n: "data" comes from the wizard
 
1217
 
 
1218
"data" comes from the wizard
 
1219
 
 
1220
.. i18n: "time" see python documentation.
 
1221
 
 
1222
"time" see python documentation.
 
1223
 
 
1224
.. i18n: "user" the user object launching the report.
 
1225
 
 
1226
"user" the user object launching the report.
 
1227
 
 
1228
.. i18n: python functions you can use:
 
1229
 
 
1230
python functions you can use:
 
1231
 
 
1232
.. i18n: "setlang('fr')" change the langage used in automated translation (fields...).
 
1233
 
 
1234
"setlang('fr')" change the langage used in automated translation (fields...).
 
1235
 
 
1236
.. i18n: "repeatIn(list,varname)" repeat the template (whole doc. or current paragraph?) for each object in the list. Use varname in the template's tags.
 
1237
 
 
1238
"repeatIn(list,varname)" repeat the template (whole doc. or current paragraph?) for each object in the list. Use varname in the template's tags.
 
1239
 
 
1240
.. i18n: "setTag('para','xpre')" change the enclosing RML tag (usually 'para') by an other (xpre is a preformatted paragraph), in the (converted from sxw)rml document (?)
 
1241
 
 
1242
"setTag('para','xpre')" change the enclosing RML tag (usually 'para') by an other (xpre is a preformatted paragraph), in the (converted from sxw)rml document (?)
 
1243
 
 
1244
.. i18n: "removeParentNode"
 
1245
 
 
1246
"removeParentNode"
 
1247
 
 
1248
.. i18n: Useful tags:
 
1249
.. i18n: ------------
 
1250
.. i18n:     [ repeatIn(objects,'o') ] objects to be printed 
 
1251
.. i18n:     repeatIn(o.invoice_line,'l') print every line 
 
1252
.. i18n:     o.quantity * o.price Operations are OK. 
 
1253
.. i18n:     '07d' int(o.number) number formating 
 
1254
.. i18n:     reduce(lambda x obj: x+obj.qty , list , 0 ) total qty of list (try "objects" as list) 
 
1255
.. i18n:     user.name user name. 
 
1256
.. i18n:     setLang(o.partner_id.lang) Localized printings 
 
1257
.. i18n:     time.strftime('%d/%m/%Y') format=dd MM YYYY, check python doc for more about "%d", ... 
 
1258
.. i18n:     [[ time.strftime(time.ctime()[0:10]) ]] [[ time.strftime(time.ctime()[-4:]) ]] prints only date. 
 
1259
.. i18n:     time.ctime() it prints the actual date & time. 
 
1260
.. i18n:     [[ time.ctime().split()[3] ]] prints only time 
 
1261
 
 
1262
Useful tags:
 
1263
------------
 
1264
    [ repeatIn(objects,'o') ] objects to be printed 
 
1265
    repeatIn(o.invoice_line,'l') print every line 
 
1266
    o.quantity * o.price Operations are OK. 
 
1267
    '07d' int(o.number) number formating 
 
1268
    reduce(lambda x obj: x+obj.qty , list , 0 ) total qty of list (try "objects" as list) 
 
1269
    user.name user name. 
 
1270
    setLang(o.partner_id.lang) Localized printings 
 
1271
    time.strftime('%d/%m/%Y') format=dd MM YYYY, check python doc for more about "%d", ... 
 
1272
    [[ time.strftime(time.ctime()[0:10]) ]] [[ time.strftime(time.ctime()[-4:]) ]] prints only date. 
 
1273
    time.ctime() it prints the actual date & time. 
 
1274
    [[ time.ctime().split()[3] ]] prints only time 
 
1275
 
 
1276
.. i18n: one more interesting tag: if you want to print out the creator of an entry (create_uid) or the last one who wrote on an entry (write_uid) you have to add something like this to the class your report refers to:
 
1277
 
 
1278
one more interesting tag: if you want to print out the creator of an entry (create_uid) or the last one who wrote on an entry (write_uid) you have to add something like this to the class your report refers to:
 
1279
 
 
1280
.. i18n:     'create_uid': fields.many2one('res.users', 'User', readonly=1) 
 
1281
 
 
1282
    'create_uid': fields.many2one('res.users', 'User', readonly=1) 
 
1283
 
 
1284
.. i18n: and then in your report it's like this to print out the corresponding name:
 
1285
 
 
1286
and then in your report it's like this to print out the corresponding name:
 
1287
 
 
1288
.. i18n:     o.create_uid.name 
 
1289
 
 
1290
    o.create_uid.name 
 
1291
 
 
1292
.. i18n: Sometimes you might want to print out something only if a certain condition is fullfilled. You can construct it with the pyhton logical operators "not", "and" and "or". Because every object in python has a logical value (TRUE or FALSE) you can construct something like this:
 
1293
 
 
1294
Sometimes you might want to print out something only if a certain condition is fullfilled. You can construct it with the pyhton logical operators "not", "and" and "or". Because every object in python has a logical value (TRUE or FALSE) you can construct something like this:
 
1295
 
 
1296
.. i18n:     (o.prop=='draft') and 'YES' or 'NO' print YES or NO 
 
1297
 
 
1298
    (o.prop=='draft') and 'YES' or 'NO' print YES or NO 
 
1299
 
 
1300
.. i18n: it works like this:
 
1301
 
 
1302
it works like this:
 
1303
 
 
1304
.. i18n: and: first value is TRUE then print out the second value. First value is FALSE print out first value.
 
1305
 
 
1306
and: first value is TRUE then print out the second value. First value is FALSE print out first value.
 
1307
 
 
1308
.. i18n: or: first value is TRUE then print out the first value. First value is FALSE print out second value. in this example if o.prop=='draft' -> TRUE then **(o.prop=='draft') and 'YES'** reads **'Yes'**. Next step is     'Yes' or 'No' which leads to a printed 'YES' (because a string's logical value is TRUE). If o.prop=='draft' -> FALSE then it reads FALSE or 'No'. So 'No' is printed. One can use very comlpex structures. To learn more search for some pyhton reference regarding logical opertors.
 
1309
 
 
1310
or: first value is TRUE then print out the first value. First value is FALSE print out second value. in this example if o.prop=='draft' -> TRUE then **(o.prop=='draft') and 'YES'** reads **'Yes'**. Next step is      'Yes' or 'No' which leads to a printed 'YES' (because a string's logical value is TRUE). If o.prop=='draft' -> FALSE then it reads FALSE or 'No'. So 'No' is printed. One can use very comlpex structures. To learn more search for some pyhton reference regarding logical opertors.
 
1311
 
 
1312
.. i18n: python function "filter" can... filter: try something like:
 
1313
 
 
1314
python function "filter" can... filter: try something like:
 
1315
 
 
1316
.. i18n:     repeatIn(filter( lambda l: l.product_id.type=='service' ,o.invoice_line), 'line') 
 
1317
 
 
1318
    repeatIn(filter( lambda l: l.product_id.type=='service' ,o.invoice_line), 'line') 
 
1319
 
 
1320
.. i18n: for printing only product with type='service' in a line's section.
 
1321
 
 
1322
for printing only product with type='service' in a line's section.
 
1323
 
 
1324
.. i18n: To display binary field image on report (to be checked)
 
1325
 
 
1326
To display binary field image on report (to be checked)
 
1327
 
 
1328
.. i18n:     [[ setTag('para','image',{'width':'100.0','height':'80.0'}) ]] o.image or setTag('image','para') 
 
1329
.. i18n:  
 
1330
 
 
1331
    [[ setTag('para','image',{'width':'100.0','height':'80.0'}) ]] o.image or setTag('image','para') 
 
1332
 
 
1333
 
 
1334
.. i18n: Unicode reports 
 
1335
.. i18n: ===============
 
1336
 
 
1337
Unicode reports 
 
1338
===============
 
1339
 
 
1340
.. i18n: As of OpenERP 5.0-rc3 unicode printing with ReportLab is still not available. The problem is that OpenERP uses the PDF standard fonts (14 fonts, they are not embedded in the document but the reader provides them) that are Type1 and have only Latin1 characters.
 
1341
 
 
1342
As of OpenERP 5.0-rc3 unicode printing with ReportLab is still not available. The problem is that OpenERP uses the PDF standard fonts (14 fonts, they are not embedded in the document but the reader provides them) that are Type1 and have only Latin1 characters.
 
1343
 
 
1344
.. i18n: The solution consists of 3 parts
 
1345
.. i18n: --------------------------------
 
1346
 
 
1347
The solution consists of 3 parts
 
1348
--------------------------------
 
1349
 
 
1350
.. i18n:     * Provide TrueType fonts and make them accessible for ReportLab.
 
1351
.. i18n:     * Register the TrueType fonts with ReportLab before using them in the reports.
 
1352
.. i18n:     * Replace the old fontNames in xsl and rml templates with the TrueType ones. 
 
1353
 
 
1354
    * Provide TrueType fonts and make them accessible for ReportLab.
 
1355
    * Register the TrueType fonts with ReportLab before using them in the reports.
 
1356
    * Replace the old fontNames in xsl and rml templates with the TrueType ones. 
 
1357
 
 
1358
.. i18n: All these ideas are taken from the forums
 
1359
.. i18n: -----------------------------------------
 
1360
 
 
1361
All these ideas are taken from the forums
 
1362
-----------------------------------------
 
1363
 
 
1364
.. i18n: **Free TrueType fonts**
 
1365
 
 
1366
**Free TrueType fonts**
 
1367
 
 
1368
.. i18n: that can be used for this purpose are in the DejaVu family. http://dejavu-fonts.org/wiki/index.php?title=Main_Page They can be installed
 
1369
 
 
1370
that can be used for this purpose are in the DejaVu family. http://dejavu-fonts.org/wiki/index.php?title=Main_Page They can be installed
 
1371
 
 
1372
.. i18n:     * in the ReportLab's fonts directory,
 
1373
.. i18n:     * system-wide and include that directory in rl_config.py,
 
1374
.. i18n:     * in a subdirectory of the OpenERP installation and give that path to ReportLab during the font registration. 
 
1375
 
 
1376
    * in the ReportLab's fonts directory,
 
1377
    * system-wide and include that directory in rl_config.py,
 
1378
    * in a subdirectory of the OpenERP installation and give that path to ReportLab during the font registration. 
 
1379
 
 
1380
.. i18n: **In the server/bin/report/render/rml2pdf/__init__.py**
 
1381
.. i18n: ::
 
1382
.. i18n: 
 
1383
.. i18n:        import reportlab.rl_config
 
1384
.. i18n:        reportlab.rl_config.warnOnMissingFontGlyphs = 0
 
1385
 
 
1386
**In the server/bin/report/render/rml2pdf/__init__.py**
 
1387
::
 
1388
 
 
1389
        import reportlab.rl_config
 
1390
        reportlab.rl_config.warnOnMissingFontGlyphs = 0
 
1391
 
 
1392
.. i18n:        from reportlab.pdfbase import pdfmetrics
 
1393
.. i18n:        from reportlab.pdfbase.ttfonts import TTFont
 
1394
.. i18n:        import reportlab
 
1395
 
 
1396
        from reportlab.pdfbase import pdfmetrics
 
1397
        from reportlab.pdfbase.ttfonts import TTFont
 
1398
        import reportlab
 
1399
 
 
1400
.. i18n:        enc = 'UTF-8'
 
1401
 
 
1402
        enc = 'UTF-8'
 
1403
 
 
1404
.. i18n:        #repeat these for all the fonts needed
 
1405
.. i18n:        pdfmetrics.registerFont(TTFont('DejaVuSans', 'DejaVuSans.ttf',enc))
 
1406
.. i18n:        pdfmetrics.registerFont(TTFont('DejaVuSans-Bold', 'DejaVuSans-Bold.ttf',enc))
 
1407
 
 
1408
        #repeat these for all the fonts needed
 
1409
        pdfmetrics.registerFont(TTFont('DejaVuSans', 'DejaVuSans.ttf',enc))
 
1410
        pdfmetrics.registerFont(TTFont('DejaVuSans-Bold', 'DejaVuSans-Bold.ttf',enc))
 
1411
 
 
1412
.. i18n:        from reportlab.lib.fonts import addMapping
 
1413
 
 
1414
        from reportlab.lib.fonts import addMapping
 
1415
 
 
1416
.. i18n:        #repeat these for all the fonts needed
 
1417
.. i18n:        addMapping('DejaVuSans', 0, 0, 'DejaVuSans') #normal
 
1418
.. i18n:        addMapping('DejaVuSans-Bold', 1, 0, 'DejaVuSans') #normal
 
1419
 
 
1420
        #repeat these for all the fonts needed
 
1421
        addMapping('DejaVuSans', 0, 0, 'DejaVuSans') #normal
 
1422
        addMapping('DejaVuSans-Bold', 1, 0, 'DejaVuSans') #normal
 
1423
 
 
1424
.. i18n: trml2pdf.py should be modified to load this if invoked from the command line.
 
1425
 
 
1426
trml2pdf.py should be modified to load this if invoked from the command line.
 
1427
 
 
1428
.. i18n: **All the xsl and rml files have to be modified**
 
1429
 
 
1430
**All the xsl and rml files have to be modified**
 
1431
 
 
1432
.. i18n: A list of possible alternatives:
 
1433
.. i18n: ::
 
1434
.. i18n: 
 
1435
.. i18n:        'Times-Roman',       'DejaVuSerif.ttf'
 
1436
.. i18n:        'Times-BoldItalic',  'DejaVuSerif-BoldItalic.ttf'
 
1437
.. i18n:        'Times-Bold',        'DejaVuSerif-Bold.ttf'
 
1438
.. i18n:        'Times-Italic',      'DejaVuSerif-Italic.ttf'
 
1439
 
 
1440
A list of possible alternatives:
 
1441
::
 
1442
 
 
1443
        'Times-Roman',       'DejaVuSerif.ttf'
 
1444
        'Times-BoldItalic',  'DejaVuSerif-BoldItalic.ttf'
 
1445
        'Times-Bold',        'DejaVuSerif-Bold.ttf'
 
1446
        'Times-Italic',      'DejaVuSerif-Italic.ttf'
 
1447
 
 
1448
.. i18n:        'Helvetica',     'DejaVuSans.ttf'
 
1449
.. i18n:        'Helvetica-BoldItalic',  'DejaVuSans-BoldOblique.ttf'
 
1450
.. i18n:        'Helvetica-Bold',    'DejaVuSans-Bold.ttf'
 
1451
.. i18n:        'Helvetica-Italic',  'DejaVuSans-Oblique.ttf'
 
1452
 
 
1453
        'Helvetica',     'DejaVuSans.ttf'
 
1454
        'Helvetica-BoldItalic',  'DejaVuSans-BoldOblique.ttf'
 
1455
        'Helvetica-Bold',    'DejaVuSans-Bold.ttf'
 
1456
        'Helvetica-Italic',  'DejaVuSans-Oblique.ttf'
 
1457
 
 
1458
.. i18n:        'Courier',           'DejaVuSansMono.ttf'
 
1459
.. i18n:        'Courier-Bold',      'DejaVuSansMono-Bold.ttf'
 
1460
.. i18n:        'Courier-BoldItalic','DejaVuSansMono-BoldOblique.ttf'
 
1461
.. i18n:        'Courier-Italic',    'DejaVuSansMono-Oblique.ttf'
 
1462
 
 
1463
        'Courier',           'DejaVuSansMono.ttf'
 
1464
        'Courier-Bold',      'DejaVuSansMono-Bold.ttf'
 
1465
        'Courier-BoldItalic','DejaVuSansMono-BoldOblique.ttf'
 
1466
        'Courier-Italic',    'DejaVuSansMono-Oblique.ttf'
 
1467
 
 
1468
.. i18n:        'Helvetica-ExtraLight',  'DejaVuSans-ExtraLight.ttf'
 
1469
 
 
1470
        'Helvetica-ExtraLight',  'DejaVuSans-ExtraLight.ttf'
 
1471
 
 
1472
.. i18n:        'TimesCondensed-Roman',      'DejaVuSerifCondensed.ttf'
 
1473
.. i18n:        'TimesCondensed-BoldItalic', 'DejaVuSerifCondensed-BoldItalic.ttf'
 
1474
.. i18n:        'TimesCondensed-Bold',       'DejaVuSerifCondensed-Bold.ttf'
 
1475
.. i18n:        'TimesCondensed-Italic',     'DejaVuSerifCondensed-Italic.ttf'
 
1476
 
 
1477
        'TimesCondensed-Roman',      'DejaVuSerifCondensed.ttf'
 
1478
        'TimesCondensed-BoldItalic', 'DejaVuSerifCondensed-BoldItalic.ttf'
 
1479
        'TimesCondensed-Bold',       'DejaVuSerifCondensed-Bold.ttf'
 
1480
        'TimesCondensed-Italic',     'DejaVuSerifCondensed-Italic.ttf'
 
1481
 
 
1482
.. i18n:        'HelveticaCondensed',        'DejaVuSansCondensed.ttf'
 
1483
.. i18n:        'HelveticaCondensed-BoldItalic', 'DejaVuSansCondensed-BoldOblique.ttf'
 
1484
.. i18n:        'HelveticaCondensed-Bold',   'DejaVuSansCondensed-Bold.ttf'
 
1485
.. i18n:        'HelveticaCondensed-Italic', 'DejaVuSansCondensed-Oblique.ttf
 
1486
 
 
1487
        'HelveticaCondensed',        'DejaVuSansCondensed.ttf'
 
1488
        'HelveticaCondensed-BoldItalic', 'DejaVuSansCondensed-BoldOblique.ttf'
 
1489
        'HelveticaCondensed-Bold',   'DejaVuSansCondensed-Bold.ttf'
 
1490
        'HelveticaCondensed-Italic', 'DejaVuSansCondensed-Oblique.ttf
 
1491
 
 
1492
.. i18n:        
 
1493
 
 
1494