Ir al contenido
Menú
Se marcó esta pregunta
3 Respuestas
1627 Vistas

Hello Friends,

I need some help in printing internal transfer entries using thermal printer.

Avatar
Descartar
Mejor respuesta

To print internal transfer receipts using a thermal printer in Odoo 17, you'll need to configure a custom report format suitable for thermal printing and ensure it is connected to the stock transfer process. Here's a step-by-step guide:

1. Understand the Requirements

  • Internal Transfer Receipts: Refers to printing a formatted document that details the products being transferred between warehouses.
  • Thermal Printer: Requires compact, printer-friendly formatting for smaller receipt sizes.

2. Create a Custom QWeb Report for Internal Transfers

Odoo uses QWeb for rendering reports. You’ll need to define a new QWeb report that is tailored for thermal printers.

Steps to Create the Report:

  1. Create a Custom Module If you don’t already have a custom module, create one with the following structure:
    custom_internal_transfer_report/
    ├── __init__.py
    ├── __manifest__.py
    ├── reports/
    │   ├── internal_transfer_report.xml
    │   └── report_templates.xml
    
  2. Update __manifest__.py Define your module and ensure it depends on the stock module:
    {
        'name': 'Internal Transfer Thermal Report',
        'version': '1.0',
        'depends': ['stock'],
        'data': [
            'reports/internal_transfer_report.xml',
            'reports/report_templates.xml',
        ],
        'installable': True,
    }
    
  3. Define the Report in internal_transfer_report.xml Link the report to the internal transfer model (stock.picking):
    <odoo>
        <report
            id="action_report_internal_transfer"
            model="stock.picking"
            string="Internal Transfer Receipt"
            report_type="qweb-pdf"
            file="custom_internal_transfer_report.report_internal_transfer"
            name="custom_internal_transfer_report.report_internal_transfer"
            print_report_name="'Internal Transfer - %s' % (object.name)"
        />
    </odoo>
    
  4. Create the Report Template in report_templates.xml Design a compact layout for the thermal printer:
    <odoo>
        <template id="report_internal_transfer">
            <t t-call="web.basic_layout">
                <div class="page">
                    <div class="text-center">
                        <h3>Internal Transfer</h3>
                        <p><strong>Reference:</strong> <t t-esc="doc.name"/></p>
                        <p><strong>Date:</strong> <t t-esc="doc.scheduled_date"/></p>
                    </div>
                    <table class="table table-condensed">
                        <thead>
                            <tr>
                                <th>Product</th>
                                <th>Quantity</th>
                                <th>Unit</th>
                            </tr>
                        </thead>
                        <tbody>
                            <t t-foreach="doc.move_ids_without_package" t-as="line">
                                <tr>
                                    <td><t t-esc="line.product_id.display_name"/></td>
                                    <td><t t-esc="line.product_uom_qty"/></td>
                                    <td><t t-esc="line.product_uom.name"/></td>
                                </tr>
                            </t>
                        </tbody>
                    </table>
                </div>
            </t>
        </template>
    </odoo>
    
  5. Connect the Report to Internal Transfers
    • Go to Inventory > Configuration > Document Layouts.
    • Assign your custom report as the default report for internal transfers.

3. Adjust the Report for Thermal Printing

Thermal printers typically require smaller paper sizes and specific styles.

  • Set Page Size: In your template, add a style block:
    <style>
        @media print {
            @page {
                size: 80mm auto; /* Adjust for your thermal printer */
                margin: 5mm;
            }
            body {
                font-size: 10px;
            }
            table {
                width: 100%;
                border-collapse: collapse;
            }
            th, td {
                border: 1px solid black;
                padding: 5px;
            }
        }
    </style>
    
  • Test the Output: Print the receipt to your thermal printer and tweak the layout as needed.

4. Add a Button for Printing

To make printing easier for users, add a button in the Internal Transfer form view.

Modify the internal_transfer_report.xml:

<record id="stock_picking_internal_form_view" model="ir.ui.view">
   <field name="name">stock.picking.internal.form</field>
   <field name="model">stock.picking</field>
   <field name="inherit_id" ref="stock.view_picking_form"/>
   <field name="arch" type="xml">
       <xpath expr="//header" position="inside">
           <button name="%(action_report_internal_transfer)d" string="Print Receipt"
                   type="action" class="btn-primary" />
       </xpath>
   </field>
</record>

5. Install and Test

  1. Restart your Odoo server and install your custom module.
  2. Create an internal transfer and validate it.
  3. Use the Print Receipt button to generate and print the thermal receipt.

6. Advanced Features (Optional)

  • Auto-Print After Validation: If you want the receipt to print automatically after validation, add this functionality to the button_validate method in stock.picking.
  • QR/Barcode for Tracking: Add a QR or barcode to the receipt for easier tracking. Use the barcode widget in your QWeb template:
    <img t-att-src="'/report/barcode/?type=QR&value=%s' % doc.name"/>
    

Conclusion

By following these steps, you can print internal transfer receipts using a thermal printer in Odoo 17. Let me know if you need further help or clarification with any part of the process!

Avatar
Descartar
Autor Mejor respuesta

Hello Yuri,

I want to print receipts from internal transfer this is only for labels solutions does not support printing receipts.

Avatar
Descartar
Mejor respuesta

Hello Ronny,

You can print labels from stock transfers (including internal transfers) with this Stock Product Labels solution.


Best regards, Yurii Razumovskyi.

Company Garazd CreationOdoo solutions for e-Commerce, SEO, Data Feeds, Website Tracking, Marketing, Analytics, and Marketplace integrations, Product Label designing and printing.

https://garazd.biz  |  Our solutions on Odoo Apps

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
2
jul 25
1963
0
mar 25
1056
1
jul 24
1928
7
jul 24
25137
2
abr 24
3314