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 @@
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>