<?xml version="1.0"?>
<document filename="test.pdf">
  <template pageSize="(595.0,842.0)" title="Test" author="Martin Simon" allowSplitting="20">
    <pageTemplate id="first">
      <frame id="first" x1="57.0" y1="57.0" width="481" height="728"/>
    </pageTemplate>
  </template>
  <stylesheet>
    <blockTableStyle id="Standard_Outline">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
    </blockTableStyle>
    <blockTableStyle id="Table1">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
      <lineStyle kind="GRID" colorName="black"/>
    </blockTableStyle>
    <blockTableStyle id="Table2">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
    </blockTableStyle>
    <blockTableStyle id="Table3">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
      <lineStyle kind="GRID" colorName="black"/>
      <blockBackground colorName="#808080" start="0,0" stop="0,0"/>
      <blockBackground colorName="#808080" start="1,0" stop="1,0"/>
      <blockBackground colorName="#808080" start="2,0" stop="2,0"/>
      <blockBackground colorName="#808080" start="3,0" stop="3,0"/>
      <blockBackground colorName="#808080" start="4,0" stop="4,0"/>
      <blockBackground colorName="#808080" start="5,0" stop="5,0"/>
      <blockBackground colorName="#808080" start="6,0" stop="6,0"/>
      <blockBackground colorName="#808080" start="7,0" stop="7,0"/>
    </blockTableStyle>
    <blockTableStyle id="Table4">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
      <lineStyle kind="GRID" colorName="black"/>
      <blockBackground colorName="#cccccc" start="0,0" stop="0,0"/>
      <blockBackground colorName="#cccccc" start="1,0" stop="1,0"/>
      <blockBackground colorName="#cccccc" start="2,0" stop="2,0"/>
      <blockBackground colorName="#cccccc" start="3,0" stop="3,0"/>
      <blockBackground colorName="#cccccc" start="4,0" stop="4,0"/>
      <blockBackground colorName="#cccccc" start="5,0" stop="5,0"/>
      <blockBackground colorName="#cccccc" start="6,0" stop="6,0"/>
      <blockBackground colorName="#cccccc" start="7,0" stop="7,0"/>
    </blockTableStyle>
    <blockTableStyle id="Table7">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
      <lineStyle kind="GRID" colorName="black"/>
    </blockTableStyle>
    <blockTableStyle id="Table6">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
      <lineStyle kind="GRID" colorName="black"/>
    </blockTableStyle>
    <initialize>
      <paraStyle name="all" alignment="justify"/>
    </initialize>
    <paraStyle name="P1" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="CENTER"/>
    <paraStyle name="P2" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="LEFT"/>
    <paraStyle name="P3" fontName="Times-Roman" fontSize="12.0" leading="15" alignment="CENTER"/>
    <paraStyle name="P4" fontName="Times-Roman" fontSize="25.0" leading="31" alignment="CENTER"/>
    <paraStyle name="P5" fontName="Times-Roman"/>
    <paraStyle name="P6" fontName="Times-Roman" fontSize="10.0" leading="13"/>
    <paraStyle name="P7" fontName="Times-Roman" fontSize="10.0" leading="13"/>
    <paraStyle name="P8" fontName="Times-Bold" fontSize="8.0" leading="10" alignment="CENTER"/>
    <paraStyle name="P9" fontName="Times-Bold" fontSize="8.0" leading="10" alignment="CENTER"/>
    <paraStyle name="P10" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="CENTER"/>
    <paraStyle name="P11" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="CENTER"/>
    <paraStyle name="P12" fontName="Times-Roman" fontSize="8.0" leading="10" alignment="CENTER"/>
    <paraStyle name="P13" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="LEFT"/>
    <paraStyle name="P14" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="CENTER"/>
    <paraStyle name="P15" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT"/>
    <paraStyle name="P16" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="LEFT"/>
    <paraStyle name="P17" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="RIGHT"/>
    <paraStyle name="P18" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="LEFT"/>
    <paraStyle name="P19" fontName="Times-Roman"/>
    <paraStyle name="P20" fontName="Times-Roman" fontSize="9.0" leading="11"/>
    <paraStyle name="P21" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="CENTER"/>
    <paraStyle name="P22" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="RIGHT"/>
    <paraStyle name="P23" fontName="Times-Roman" fontSize="10.0" leading="13"/>
    <paraStyle name="Standard" fontName="Times-Roman"/>
    <paraStyle name="Text body" fontName="Times-Roman" spaceBefore="0.0" spaceAfter="6.0"/>
    <paraStyle name="Footer" fontName="Times-Roman"/>
    <paraStyle name="Table Contents" fontName="Times-Roman"/>
    <paraStyle name="Table Heading" fontName="Times-Roman" alignment="CENTER"/>
    <paraStyle name="Horizontal Line" fontName="Times-Roman" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="14.0"/>
  </stylesheet>
  <story>
    <para style="P1">[[ repeatIn(objects, 'o') ]]</para>
    <para style="P2">
      <font color="white"> </font>
    </para>
    <para style="P3">Sale Order [[ o.name ]]</para>
    <para style="P4">[[ o.state!='done' and 'draft' or '' ]]</para>
    <para style="P2">
      <font color="white"> </font>
    </para>
    <blockTable colWidths="241.0,241.0" repeatRows="1" style="Table1">
      <tr>
        <td>
          <para style="P5">Shipping to</para>
          <para style="P6">[[ o.partner_shipping_id.partner_id.name ]]</para>
          <para style="P7">[[ o.partner_shipping_id.street ]]</para>
          <para style="P7">[[ o.partner_shipping_id.zip ]] [[ o.partner_shipping_id.city ]]</para>
        </td>
        <td>
          <para style="P5">Ordered by</para>
          <para style="P6">[[ o.partner_order_id.partner_id.name ]]</para>
          <para style="P7">[[ o.partner_order_id.street ]]</para>
          <para style="P7">[[ o.partner_order_id.zip ]] [[ o.partner_order_id.city ]]</para>
        </td>
      </tr>
    </blockTable>
    <para style="Standard">
      <font color="white"> </font>
    </para>
    <blockTable colWidths="98.0,88.0,90.0,101.0,106.0" repeatRows="1" style="Table2">
      <tr>
        <td>
          <para style="P8">Order ref.</para>
        </td>
        <td>
          <para style="P9">Order date</para>
        </td>
        <td>
          <para style="P9">Shipping date </para>
        </td>
        <td>
          <para style="P9">Delivery date 1</para>
        </td>
        <td>
          <para style="P9">Delivery date 2</para>
        </td>
      </tr>
      <tr>
        <td>
          <para style="P10">[[ o.name ]]</para>
        </td>
        <td>
          <para style="P10">[[ o.date_order ]]</para>
        </td>
        <td>
          <para style="P10">
            <font color="white"> </font>
          </para>
        </td>
        <td>
          <para style="P11">
            <font color="white"> </font>
          </para>
        </td>
        <td>
          <para style="P11">[[reduce(lambda x, line: line.date_planned&gt;x and line.date_planned or x, o.order_line, '')]]</para>
        </td>
      </tr>
    </blockTable>
    <blockTable colWidths="79.0,160.0,35.0,55.0,33.0,44.0,45.0,32.0" repeatRows="1" style="Table3">
      <tr>
        <td>
          <para style="P12">Reference</para>
        </td>
        <td>
          <para style="P12">Designation</para>
        </td>
        <td>
          <para style="P12">Package</para>
        </td>
        <td>
          <para style="P12">Quantity</para>
        </td>
        <td>
          <para style="P12">S.U.</para>
        </td>
        <td>
          <para style="P12">Prepared Package</para>
        </td>
        <td>
          <para style="P12">Prepared quantity</para>
        </td>
        <td>
          <para style="P12">Batch</para>
        </td>
      </tr>
    </blockTable>
    <section>
      <para style="Text body">[[ repeatIn(o.order_line, 'line') ]]</para>
      <blockTable colWidths="78.0,160.0,36.0,54.0,34.0,44.0,45.0,31.0" style="Table4">
        <tr>
          <td>
            <para style="P13">[[line.product_id.code]]</para>
          </td>
          <td>
            <para style="P13">[[line.product_id.name]]</para>
            <para style="P13">
              <font color="white"> </font>
            </para>
            <para style="P14">
              <font color="white"> </font>
            </para>
          </td>
          <td>
            <para style="P15">[[line.number_packages]]</para>
          </td>
          <td>
            <para style="P15">[[line.product_uom_qty]]</para>
          </td>
          <td>
            <para style="P13">[[line.product_uom.name]]</para>
          </td>
          <td>
            <para style="P13">
              <font color="white"> </font>
            </para>
          </td>
          <td>
            <para style="P13">
              <font color="white"> </font>
            </para>
          </td>
          <td>
            <para style="P13">
              <font color="white"> </font>
            </para>
          </td>
        </tr>
        <tr>
          <td>
            <para style="P16">[[line.product_id.ean13]]</para>
          </td>
          <td>
            <para style="P16">Logistical unit : [[line.product_packaging.qty]]</para>
            <para style="P16">[[line.number_packages and 'Packaging : %d package of %d P' % (line.number_packages, line.product_packaging.qty) or '']]</para>
          </td>
          <td>
            <para style="P17">
              <font color="white"> </font>
            </para>
          </td>
          <td>
            <para style="P17">[[line.product_uos_qty]]</para>
          </td>
          <td>
            <para style="P18">[[line.product_uos and line.product_uos.name or '']]</para>
          </td>
          <td>
            <para style="P16">
              <font color="white"> </font>
            </para>
          </td>
          <td>
            <para style="P16">
              <font color="white"> </font>
            </para>
          </td>
          <td>
            <para style="P16">
              <font color="white"> </font>
            </para>
            <para style="P16">
              <font color="white"> </font>
            </para>
          </td>
        </tr>
      </blockTable>
    </section>
    <para style="P19">
      <font color="white"> </font>
    </para>
    <blockTable colWidths="78.0,160.0,37.0,54.0,33.0,46.0,44.0,31.0" style="Table7">
      <tr>
        <td>
          <para style="Table Contents">
            <font color="white"> </font>
          </para>
          <para style="Table Contents">
            <font color="white"> </font>
          </para>
        </td>
        <td>
          <para style="P20">Number of packages</para>
          <para style="P20">
            <font color="white"> </font>
          </para>
          <para style="P20">
            <font color="white"> </font>
          </para>
          <para style="P20">
            <font color="white"> </font>
          </para>
          <para style="P20">
            <font color="white"> </font>
          </para>
          <para style="P20">
            <font color="white"> </font>
          </para>
          <para style="P20">
            <font color="white"> </font>
          </para>
          <para style="P20">
            <font color="white"> </font>
          </para>
          <para style="P20">
            <font color="white"> </font>
          </para>
          <para style="P21">
            <font color="white"> </font>
          </para>
        </td>
        <td>
          <para style="P22">[[ reduce(lambda x, line: x+ len(line.move_lines), o.picking_ids, 0)]]</para>
        </td>
        <td>
          <para style="Table Contents">
            <font color="white"> </font>
          </para>
        </td>
        <td>
          <para style="Table Contents">
            <font color="white"> </font>
          </para>
        </td>
        <td>
          <para style="Table Contents">
            <font color="white"> </font>
          </para>
        </td>
        <td>
          <para style="Table Contents">
            <font color="white"> </font>
          </para>
        </td>
        <td>
          <para style="Table Contents">
            <font color="white"> </font>
          </para>
        </td>
      </tr>
    </blockTable>
    <para style="Standard">
      <font color="white"> </font>
    </para>
    <blockTable colWidths="482.0" repeatRows="1" style="Table6">
      <tr>
        <td>
          <para style="P19">Invoiced to : <font face="Times-Roman" size="10.0">[[ o.partner_invoice_id.partner_id.name ]]</font></para>
        </td>
      </tr>
    </blockTable>
    <para style="P23">
      <font color="white"> </font>
    </para>
  </story>
</document>

