Skip to Content
Menu
This question has been flagged
2 Replies
630 Views

In Odoo we are attempting to show information from the associated delivery ticket/sale order in Product Label (ZPL) found in Settings / Technical / Actions / Reports. 


We would like to display the customer's name, sales order number, sales order date, and the description of each item on the label. 


The product name was already a part of the label, but we can't find the way to pull the other fields from the delivery ticket when printing ZPL labels.


So we need to figure out what to add to the code to do this.  We've tried everything we can think of.


The current code in its QWeb view (label_product_product_view) is the following:

```

<t t-name="stock.label_product_pr oduct_view">

    <t t-foreach="quantity.items()" t-as="barcode_and_qty_by_produ ct">

        <t t-set="product" t-value="barcode_and_qty_by_pr oduct[0]"/>

        <t t-foreach="barcode_and_qty_by_ product[1]" t-as="product_info">

            <t t-set="barcode" t-value="product_info['barcode ']"/>

            <t t-set="currency_id" t-value="pricelist.currency_id or product.currency_id"/>

            <t t-foreach="range(product_info[ 'quantity'])" t-as="qty">

                <t t-translation="off">

^XA


^FX Second section with recipient address and permit information.

^CFJ,250

^FO50,100^FD<t t-out="product_info['display_n ame_markup']"/>^FS


^XZ

                </t>

            </t>

        </t>

    </t>

</t>

Avatar
Discard
Best Answer

I've had to do something similar and it required creating a new label, since the product label has no reference to the picking when printed. You'll need to create a label for stock.picking and then iterate over the products/move lines in the transfer.

From the transfer, you'll be able to pull the contact (res.partner) info since it has a One2Many relationship to the contact.

I've made an ASN label in the past which takes a delivery order and prints a zpl label for each move line (so each product + lot combination) with some contact info. It shows how to tell the printer to start a new label and how to go over each product in a stock.picking

<t t-name="stock.label_ASN_template_view">
    <t t-foreach="docs" t-as="transfer">
        <t t-set="contact_name" t-value="transfer.partner_id.commercial_company_name"/>
        <t t-set="contact_street" t-value="transfer.partner_id.street"/>
        <t t-set="contact_city" t-value="transfer.partner_id.city"/>
        <t t-set="contact_zip" t-value="transfer.partner_id.zip"/>
        <t t-set="contact_state" t-value="transfer.partner_id.state_id.code"/>
        <t t-set="contact_country" t-value="transfer.partner_id.country_code"/>
        <t t-set="carrier" t-value="transfer.x_studio_transporteur"/>
        <t t-set="PO" t-value="transfer.sale_id.client_order_ref"/>
        <t t-translations="off">
            <t t-foreach="transfer.move_ids" t-as="move">
                <t t-foreach="move.move_line_ids" t-as="line">
           
^XACI28

^FX Border Definitions
^FX From field
^FO2,4
^GB254,203,2
^FS

^FX To field
^FO254,4
^GB558,203,2
^FS

^FX Postal Code field
^FO2,203
^GB508,206,2
^FS

^FX Carrier info field
^FO508,203
^GB304,206,2
^FS

^FX Product info field
^FO2,409
^GB812,406,2
^FS

^FX MAN Segment field
^FO2,815
^GB812,403,2
^FS

^FX Data definitions
^FX From field
^FO10,16
^A0N,26,26^FB200,1^FDFrom/DE:
^FS

^FO20,50
^A0N,26,26^FB225,5^FDImpress Foods Inc. 1910 rue du Sanctuaire, Quebec, QC G1E 3L2
^FS

^FX To field
^FO264,16
^A0N,26,26^FB200,1^FDTo/A:
^FS

^FO284,50
^A0N,26,26^FB300,5^FD<t t-out="contact_name"/>. <t t-out="contact_street"/>, <t t-out="contact_city"/>, <t t-out="contact_state"/> <t t-out="contact_zip"/>
^FS

^FX Postal code field
^FO10,213
^A0N,26,26^FB500,1^FDShip to Postal Code:
^FS

^FO15,243
^A0N,26,26^FB500,1^FD(420)<t t-out="contact_zip"/>
^FS

^FO90,288
^BCN,100,N,N,Y^FD420<t t-out="contact_zip"/>
^FS

^FX Carrier Field
^FO518,213
^A0N,26,26^FB500,1^FDCarrier:
^FS

^FO518,243
^A0N,26,26^FB500,1^FD<t t-out="carrier"/>
^FS

^FO518,273
^A0N,26,26^FB500,1^FDPro: 12345
^FS

^FO518,303
^A0N,26,26^FB500,1^FDB/L: 123456789
^FS

^FX Product Field
^FO20,439
^A0N,40,40^FB500,1^FDPO: <t t-out="PO"/>
^FS

^FO20,489
^A0N,40,40^FB500,1^FDGTIN: <t t-out="line.product_barcode"/>
^FS

^FO500,489
^A0N,40,40^FB500,1^FDLOT: <t t-out="line.lot_id.display_name"/>
^FS

^FO20,539
^A0N,40,40^FB800,2^FDItem Description: <t t-raw="line.product_id.display_name"/>
^FS

^FO130,639
^A0N,40,40^FB800,1^FDCase QTY: <t t-out="line.quantity"/>
^FS

^FO130,689
^A0N,40,40^FB800,1^FDProduct Net Weight (KG):
^FS

^FO130,739
^A0N,40,40^FB800,1^FDCode Date: <t t-esc="line.lot_id.use_date.strftime('%Y-%m-%d')"/>
^FS

^FX MAN Segment
^FO10,822
^A0N,26,26^FB500,1^FDMAN Segment (SSCC-18):
^FS
^FO110,900
^BCN,225,Y,Y,Y,A^FD(00)003001234000000001

^XZ
                </t>
            </t>
        </t>
    </t>
</t>
Avatar
Discard
Author Best Answer

Just to clarify, we're printing from the delivery ticked so the sales order number would be the Source Document field.

Avatar
Discard
Related Posts Replies Views Activity
2
Aug 24
7174
1
Aug 24
931
0
Feb 24
623
0
Jan 20
366
0
Mar 15
3333