Multiple Product Labels for one item

Asked by Savvas Christofides on 2012-09-04

Does anyone have any idea how to print the product label of an item which has large quantities in stock in one go? Currently in 6.1 I can only print 1 at a time label of the same product. thus i need to waste the paper so many times for large quantities

Question information

Language:
English Edit question
Status:
Solved
For:
Odoo Addons (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Solved by:
Savvas Christofides
Solved:
2012-09-04
Last query:
2012-09-04
Last reply:
2012-09-04
Ferdinand (office-chricar) said : #1

On 09/04/2012 10:41 AM, Savvas Christofides wrote:
> New question #207635 on OpenERP Addons:
> https://answers.launchpad.net/openobject-addons/+question/207635
>
> Does anyone have any idea how to print the product label of an item which has large quantities in stock in one go? Currently in 6.1 I can only print 1 at a time label of the same product. thus i need to waste the paper so many times for large quantities
>
may be you should use webkit report and create a report with many labels
on one page

ferdinand

a solution :
you can create new report duplicate and use different product_label.xml and xsl file
replace code in xls

<xsl:template match="lot-line" mode="story">
        <xsl:param name="count" select="qty_available"/>
  <xsl:if test="$count>0">
         <xsl:call-template name="label_repeat">
         <xsl:with-param name="count" select="$count - 1"/>
         </xsl:call-template>
  </xsl:if>
 </xsl:template>

    <xsl:template name="label_repeat">
      <xsl:param name="count" select="1"/>
   <xsl:if test="$count>=0">
   <blockTable style="mytable" colWidths="2.8cm,5.4cm">
   <tr>
   <td>
    <para style="nospace"><xsl:value-of select="code"/></para>
   </td><td>
    <para style="nospace" t="1"><xsl:value-of select="price"/> <xsl:value-of select="currency"/>
                </para>
   </td>
   </tr><tr>
   <td>
   <barCode><xsl:value-of select="code"/></barCode>
   </td><td>
    <para style="nospace"><xsl:value-of select="product"/></para><xsl:text>, </xsl:text>
    <para style="nospace"><xsl:value-of select="variant"/></para>
   </td>
   </tr>
   </blockTable>
   <nextFrame/>
            <xsl:call-template name="label_repeat">
   <xsl:with-param name="count" select="$count - 1"/>
         </xsl:call-template>
       </xsl:if>
 </xsl:template>

and the xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<lots>
    <lot-line type="fields" name="id">
        <code type="field" name="code"/>
        <product type="field" name="name"/>
        <variant type="field" name="variants"/>
        <price type="field" name="list_price"/>
        <ean13 type="field" name="ean13"/>
        <qty_available type="field" name="qty_available"/>
        <currency type="field" name="company_id.currency_id.name"/>
    </lot-line>
</lots>

Hi
I got an updated code to print properly all the quantities of the item

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">

 <xsl:variable name="initial_bottom_pos">25.35</xsl:variable>
 <xsl:variable name="initial_left_pos">0.85</xsl:variable>
 <xsl:variable name="height_increment">2.67</xsl:variable>
 <xsl:variable name="width_increment">4.9</xsl:variable>
 <xsl:variable name="frame_height">2.60cm</xsl:variable>
 <xsl:variable name="frame_width">4.9cm</xsl:variable>
 <xsl:variable name="number_columns">4</xsl:variable>
 <xsl:variable name="max_frames">40</xsl:variable>

 <xsl:template match="/">
  <xsl:apply-templates select="lots"/>
 </xsl:template>

 <xsl:template match="lots">
  <document>
   <template leftMargin="0.0cm" rightMargin="0.0cm" topMargin="0.0cm" bottomMargin="0.0cm" title="Address list" author="Generated by Open ERP">
    <pageTemplate id="all">
     <pageGraphics/>

                    <xsl:call-template name="position_repeat">
            <xsl:with-param name="count" select="sum(lot-line//qty_available)"/>
          </xsl:call-template>

    </pageTemplate>
   </template>
   <stylesheet>
    <paraStyle name="nospace" fontName="Courier" fontSize="10" spaceBefore="0" spaceAfter="0"/>
    <blockTableStyle id="mytable">
     <blockBackground colorName="white" start="0,0" stop="0,0"/>
     <blockBackground colorName="white" start="1,0" stop="-1,0"/>
     <blockAlignment value="CENTER"/>
     <blockValign value="MIDDLE"/>
     <blockFont name="Helvetica-BoldOblique" size="14" start="0,0" stop="-1,0"/>
     <blockFont name="Helvetica" size="8" start="0,1" stop="-1,1"/>
     <lineStyle kind="GRID" colorName="white" tickness="0"/>
    </blockTableStyle>
   </stylesheet>
   <story>
    <xsl:apply-templates select="lot-line" mode="story"/>
   </story>
  </document>
 </xsl:template>

 <xsl:template name="position_repeat">
     <xsl:param name="count"/>
     <xsl:if test="$count>0">
  <xsl:if test="$count &lt; $max_frames + 1">
   <frame>
    <xsl:attribute name="width">
     <xsl:value-of select="$frame_width"/>
    </xsl:attribute>
    <xsl:attribute name="height">
     <xsl:value-of select="$frame_height"/>
    </xsl:attribute>
    <xsl:attribute name="x1">
     <xsl:value-of select="$initial_left_pos + (($count - 1) mod $number_columns) * $width_increment"/>
     <xsl:text>cm</xsl:text>
    </xsl:attribute>
    <xsl:attribute name="y1">
     <xsl:value-of select="$initial_bottom_pos - floor(($count - 1) div $number_columns) * $height_increment"/>
     <xsl:text>cm</xsl:text>
    </xsl:attribute>
   </frame>
   </xsl:if>
            <xsl:call-template name="position_repeat">
   <xsl:with-param name="count" select="$count - 1"/>
  </xsl:call-template>
     </xsl:if>
 </xsl:template>

 <xsl:template match="lot-line" mode="story">
        <xsl:param name="count" select="qty_available"/>
  <xsl:if test="$count>0">
         <xsl:call-template name="label_repeat">
          <xsl:with-param name="count" select="$count - 1"/>
        </xsl:call-template>
  </xsl:if>
 </xsl:template>

 <xsl:template name="label_repeat">
  <xsl:param name="count"/>
  <xsl:if test="$count>=0">

   <blockTable style="mytable" colWidths="4.9cm,0cm">
   <tr>
       <td>
    <barCode><xsl:value-of select="code"/></barCode>
    </td>
   </tr><tr ><td>
     <para style="nospace"><font size="5"><xsl:value-of select="product"/></font></para>
    </td>
   </tr>
                <tr><td>
     <para style="nospace" t="1">EURO: <xsl:value-of select='format-number(price, "#.00")'/></para>
    </td>
                </tr>

   </blockTable>
  <nextFrame/>
        <xsl:call-template name="label_repeat">
   <xsl:with-param name="count" select="$count - 1"/>
  </xsl:call-template>
  </xsl:if>
 </xsl:template>
</xsl:stylesheet>