<?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="Table5">
      <blockAlignment value="LEFT"/>
      <blockValign value="TOP"/>
      <lineStyle kind="GRID" colorName="black"/>
      <blockBackground colorName="#999999" start="0,0" stop="0,0"/>
      <blockBackground colorName="#999999" start="1,0" stop="1,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="25.0" leading="31" alignment="CENTER"/>
    <paraStyle name="P4" fontName="Times-Roman"/>
    <paraStyle name="P5" fontName="Times-Roman" fontSize="10.0" leading="13"/>
    <paraStyle name="P6" fontName="Times-Roman" fontSize="10.0" leading="13"/>
    <paraStyle name="P7" fontName="Times-Bold" fontSize="8.0" leading="10" alignment="CENTER"/>
    <paraStyle name="P8" fontName="Times-Bold" fontSize="8.0" leading="10" alignment="CENTER"/>
    <paraStyle name="P9" fontName="Times-Roman" 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="11.0" leading="14"/>
    <paraStyle name="P13" fontName="Times-Roman" fontSize="11.0" leading="14" alignment="LEFT"/>
    <paraStyle name="P14" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="LEFT"/>
    <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" alignment="RIGHT"/>
    <paraStyle name="P19" fontName="Times-Roman" fontSize="10.0" leading="13" alignment="LEFT"/>
    <paraStyle name="P20" fontName="Times-Roman"/>
    <paraStyle name="P21" fontName="Times-Roman" fontSize="9.0" leading="11"/>
    <paraStyle name="P22" fontName="Times-Roman" fontSize="9.0" leading="11" alignment="RIGHT"/>
    <paraStyle name="P23" fontName="Times-Roman" alignment="LEFT"/>
    <paraStyle name="P24" 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="P1">Preparation order [[ o.name ]]</para>
    <para style="P3">[[ 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="P4">Shipped to</para>
          <para style="P5">[[ o.partner_shipping_id.partner_id.name ]]</para>
          <para style="P6">[[ o.partner_shipping_id.street ]]</para>
          <para style="P6">[[ o.partner_shipping_id.zip ]] [[ o.partner_shipping_id.city ]]</para>
        </td>
        <td>
          <para style="P4">Ordered by</para>
          <para style="P5">[[ o.partner_order_id.partner_id.name ]]</para>
          <para style="P6">[[ o.partner_order_id.street ]]</para>
          <para style="P6">[[ o.partner_order_id.zip ]] [[ o.partner_order_id.city ]]</para>
        </td>
      </tr>
    </blockTable>
    <para style="Standard">
      <font color="white"> </font>
    </para>
    <blockTable colWidths="85.0,99.0,85.0,99.0,113.0" repeatRows="1" style="Table2">
      <tr>
        <td>
          <para style="P7">Order ref.</para>
        </td>
        <td>
          <para style="P8">Order date </para>
        </td>
        <td>
          <para style="P8">Shipping Date </para>
        </td>
        <td>
          <para style="P8">Delivery date 1</para>
        </td>
        <td>
          <para style="P8">Delivery date 2</para>
        </td>
      </tr>
      <tr>
        <td>
          <para style="P9">[[ o.name ]]</para>
        </td>
        <td>
          <para style="P9">[[ o.date_order ]]</para>
        </td>
        <td>
          <para style="P9">
            <font color="white"> </font>
          </para>
        </td>
        <td>
          <para style="P10">
            <font color="white"> </font>
          </para>
        </td>
        <td>
          <para style="P10">[[reduce(lambda x, line: line.date_planned&gt;x and line.date_planned or x, o.order_line, '')]]</para>
        </td>
      </tr>
    </blockTable>
    <blockTable colWidths="57.0,170.0,57.0,42.0,28.0,42.0,42.0,42.0" repeatRows="1" style="Table3">
      <tr>
        <td>
          <para style="P11">Reference</para>
        </td>
        <td>
          <para style="P11">Designation</para>
        </td>
        <td>
          <para style="P11">Package</para>
        </td>
        <td>
          <para style="P11">Quantity</para>
        </td>
        <td>
          <para style="P11">S.U</para>
        </td>
        <td>
          <para style="P11">Prepared Package</para>
        </td>
        <td>
          <para style="P11">Prepared quantity</para>
        </td>
        <td>
          <para style="P11">Batch</para>
        </td>
      </tr>
    </blockTable>
    <section>
      <para style="Text body">[[ repeatIn(allotment(o), 'lot') ]]</para>
      <blockTable colWidths="85.0,397.0" style="Table5">
        <tr>
          <td>
            <para style="P12">[[ repeatIn(lot[0], 'cust') ]] <font face="Times-Roman">Final customer:</font></para>
          </td>
          <td>
            <para style="P13">[[ cust.partner_id.name ]] - [[ cust.name ]]</para>
            <para style="P13">[[ cust.street ]]</para>
            <para style="P13">[[ cust.zip ]] [[ cust.city ]] - [[ cust.country_id.name ]]</para>
          </td>
        </tr>
      </blockTable>
      <para style="Text body">[[ repeatIn(lot[1], 'line') ]]</para>
      <blockTable colWidths="57.0,170.0,57.0,43.0,28.0,42.0,42.0,41.0" style="Table4">
        <tr>
          <td>
            <para style="P14">[[line.product_id.code]]</para>
          </td>
          <td>
            <para style="P14">[[line.product_id.name]]</para>
          </td>
          <td>
            <para style="P15">[[line.number_packages]]</para>
          </td>
          <td>
            <para style="P15">[[line.product_uom_qty]]</para>
          </td>
          <td>
            <para style="P14">[[line.product_uom.name]]</para>
          </td>
          <td>
            <para style="P14">
              <font color="white"> </font>
            </para>
          </td>
          <td>
            <para style="P14">
              <font color="white"> </font>
            </para>
          </td>
          <td>
            <para style="P14">
              <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 packages 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="P18">
              <font face="Times-Roman" size="10.0">[[line.product_uos_qty]]</font>
            </para>
          </td>
          <td>
            <para style="P19">[[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>
      <para style="P20">
        <font color="white"> </font>
      </para>
      <blockTable colWidths="57.0,170.0,57.0,42.0,28.0,42.0,42.0,41.0" style="Table7">
        <tr>
          <td>
            <para style="Table Contents">
              <font color="white"> </font>
            </para>
          </td>
          <td>
            <para style="P21">Number of packages</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="P23">
        <font color="white"> </font>
      </para>
    </section>
    <section>
      <para style="Text body">
        <font color="white"> </font>
      </para>
      <para style="Text body">
        <font color="white"> </font>
      </para>
    </section>
    <blockTable colWidths="482.0" repeatRows="1" style="Table6">
      <tr>
        <td>
          <para style="P20">Invoiced to : <font face="Times-Roman" size="10.0">[[ o.partner_invoice_id.partner_id.name ]]</font></para>
        </td>
      </tr>
    </blockTable>
    <para style="P24">
      <font color="white"> </font>
    </para>
  </story>
</document>

