from odoo import fields, models class ResCompany(models.Model): _inherit = "res.company" zpl_printer_ip = fields.Char(string="Valid ZPL Printer IP Address") zpl_printer_port = fields.Integer(string="ZPL Printer Port", default=9100) # Label Dimensions (dots) zpl_label_width = fields.Integer(string="Label Width (dots)", default=480, help="For 203dpi, 1mm ~ 8 dots. 60mm = 480 dots") zpl_label_height = fields.Integer(string="Label Height (dots)", default=240, help="30mm = 240 dots") # Margins zpl_margin_left = fields.Integer(string="Left Margin", default=10) zpl_margin_top = fields.Integer(string="Top Margin", default=10) # Content Sizing zpl_font_size = fields.Integer(string="Font Size", default=30) zpl_barcode_height = fields.Integer(string="Barcode Height", default=100) zpl_barcode_width = fields.Integer(string="Barcode Module Width", default=2, help="Narrow bar width in dots (1-10)") # Images zpl_print_logo = fields.Boolean(string="Print Company Logo", default=False) zpl_custom_image = fields.Binary(string="Custom Image") zpl_custom_image_filename = fields.Char(string="Custom Image Filename") def get_zpl_logo_string(self): self.ensure_one() if not self.zpl_print_logo or not self.logo: return "" try: from .printer_utils import convert_to_zpl_hex import base64 # Decode logo image_data = base64.b64decode(self.logo) # Resize to reasonable small logo size, e.g. 150x150 dots zpl_hex = convert_to_zpl_hex(image_data, width_dots=150, height_dots=150) return zpl_hex except Exception as e: return "" def get_zpl_custom_image_string(self): self.ensure_one() if not self.zpl_custom_image: return "" try: from .printer_utils import convert_to_zpl_hex import base64 image_data = base64.b64decode(self.zpl_custom_image) # Resize to reasonable small icon size, e.g. 100x100 dots zpl_hex = convert_to_zpl_hex(image_data, width_dots=100, height_dots=100) return zpl_hex except Exception as e: return ""