Add module product_print_zpl_barcode_cups

This commit is contained in:
Alexis de Lattre
2025-06-17 11:16:20 +00:00
parent c82efba0af
commit 0c97c7e1b2
6 changed files with 79 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
Product Print ZPL Barcode via CUPS
==================================
This is a glue module between product_print_zpl_barcode (same repository) and base_report_to_printer (from `OCA/report-print-send <https://github.com/OCA/report-print-send>`). It is useful when you have an USB ZPL printer that you can only reach via CUPS.
This module has been written by Alexis de Lattre from Akretion France <alexis.delattre@akretion.com>.

View File

@@ -0,0 +1 @@
from . import wizards

View File

@@ -0,0 +1,21 @@
# Copyright 2016-2020 Akretion (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Product Print ZPL Barcode via CUPS',
'version': '16.0.1.0.0',
'category': 'Extra Tools',
'license': 'AGPL-3',
'summary': 'Glue module between product_print_zpl_barcode and base_report_to_printer',
'author': 'Akretion',
'website': 'https://github.com/akretion/odoo-usability',
'depends': [
'product_print_zpl_barcode',
'base_report_to_printer',
],
'data': [
'wizards/product_print_zpl_barcode_view.xml',
],
'installable': True,
}

View File

@@ -0,0 +1 @@
from . import product_print_zpl_barcode

View File

@@ -0,0 +1,26 @@
# Copyright 2025 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
import base64
class ProductPrintZplBarcode(models.TransientModel):
_inherit = 'product.print.zpl.barcode'
zpl_printer_id = fields.Many2one('printing.printer', string='ZPL Printer')
@api.model
def default_get(self, fields_list):
res = super().default_get(fields_list)
printer = self.env['printing.printer'].get_default()
res['zpl_printer_id'] = printer and printer.id or False
return res
def print_zpl(self):
if self.zpl_printer_id:
self.zpl_printer_id.print_document(
self.zpl_filename, base64.decodebytes(self.zpl_file), format='raw')
else:
return super().print_zpl()

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2025 Akretion France (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="product_print_zpl_barcode_form" model="ir.ui.view">
<field name="name">product_print_zpl_barcode.CUPS.form</field>
<field name="model">product.print.zpl.barcode</field>
<field name="inherit_id" ref="product_print_zpl_barcode.product_print_zpl_barcode_form"/>
<field name="arch" type="xml">
<field name="zpl_printer_ip" position="attributes">
<attribute name="attrs">{'invisible': 1}</attribute>
</field>
<field name="zpl_printer_ip" position="after">
<field name="zpl_printer_id" attrs="{'required': [('state', '=', 'step2')]}"/>
</field>
</field>
</record>
</odoo>