01c5ca4059e9598b0c21b7de65a18dd409352779
[odoo/odoo.git] / addons / product / report / product_label.xsl
1 <?xml version="1.0" encoding="utf-8"?>
2 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
3         <xsl:variable name="initial_bottom_pos">24.5</xsl:variable>
4         <xsl:variable name="initial_left_pos">0.5</xsl:variable>
5         <xsl:variable name="height_increment">4.8</xsl:variable>
6         <xsl:variable name="width_increment">10</xsl:variable>
7         <xsl:variable name="frame_height">3cm</xsl:variable>
8         <xsl:variable name="frame_width">9.3cm</xsl:variable>
9         <xsl:variable name="number_columns">2</xsl:variable>
10         <xsl:variable name="max_frames">16</xsl:variable>
11
12         <xsl:template match="/">
13                 <xsl:apply-templates select="lots"/>
14         </xsl:template>
15
16         <xsl:template match="lots">
17                 <document>
18                         <template leftMargin="2.0cm" rightMargin="2.0cm" topMargin="2.0cm" bottomMargin="2.0cm" title="Address list" author="Generated by Odoo">
19                                 <pageTemplate id="all">
20                                         <pageGraphics/>
21                                         <xsl:apply-templates select="lot-line" mode="frames"/>
22                                 </pageTemplate>
23                         </template>
24                         <stylesheet>
25                                 <paraStyle name="nospace" fontName="Courier" fontSize="10" spaceBefore="0" spaceAfter="0"/>
26                                 <blockTableStyle id="mytable">
27                                         <blockBackground colorName="lightred" start="0,0" stop="0,0"/>
28                                         <blockBackground colorName="lightgrey" start="1,0" stop="-1,0"/>
29                                         <blockAlignment value="CENTER"/>
30                                         <blockValign value="MIDDLE"/>
31                                         <blockFont name="Helvetica-BoldOblique" size="14" start="0,0" stop="-1,0"/>
32                                         <blockFont name="Helvetica" size="8" start="0,1" stop="-1,1"/>
33                                         <lineStyle kind="GRID" colorName="black" tickness="1"/>
34                                 </blockTableStyle>
35                         </stylesheet>
36                         <story>
37                                 <xsl:apply-templates select="lot-line" mode="story"/>
38                         </story>
39                 </document>
40         </xsl:template>
41
42         <xsl:template match="lot-line" mode="frames">
43                 <xsl:if test="position() &lt; $max_frames + 1">
44                         <frame>
45                                 <xsl:attribute name="width">
46                                         <xsl:value-of select="$frame_width"/>
47                                 </xsl:attribute>
48                                 <xsl:attribute name="height">
49                                         <xsl:value-of select="$frame_height"/>
50                                 </xsl:attribute>
51                                 <xsl:attribute name="x1">
52                                         <xsl:value-of select="$initial_left_pos + ((position()-1) mod $number_columns) * $width_increment"/>
53                                         <xsl:text>cm</xsl:text>
54                                 </xsl:attribute>
55                                 <xsl:attribute name="y1">
56                                         <xsl:value-of select="$initial_bottom_pos - floor((position()-1) div $number_columns) * $height_increment"/>
57                                         <xsl:text>cm</xsl:text>
58                                 </xsl:attribute>
59                         </frame>
60                 </xsl:if>
61         </xsl:template>
62
63     <xsl:param name="pmaxChars" as="xs:integer" select="80"/>
64
65         <xsl:template match="lot-line" mode="story">
66             <blockTable style="mytable" colWidths="2.8cm,5.4cm">
67                 <tr>
68                     <td>
69                         <para style="nospace"><xsl:value-of select="code"/></para>
70                     </td>
71                     <td>
72                         <para style="nospace" t="1"><xsl:value-of select="price"/><xsl:text>  </xsl:text><xsl:value-of select="currency"/></para>
73                     </td>
74                 </tr>
75                 <tr>
76                     <td>
77                         <barCode><xsl:value-of select="barcode" /></barCode> 
78                     </td>
79                     <td>
80                         <para style="nospace"><xsl:value-of select="substring(product, 1, pmaxChars)"/></para><xsl:text>, </xsl:text>
81                         <para style="nospace"><xsl:value-of select="variant"/></para>
82                     </td>
83                 </tr>
84             </blockTable>
85         <nextFrame/>
86         </xsl:template>
87 </xsl:stylesheet>