# -*- coding: utf-8 -*- import ctypes from odoo import models class Common(models.Model): _name = 'sf.sync.common' _description = u'公用类' def print_zpl(self, zpl_str): WinDll_path = "D://桌面//pythonZPL//zebra_zpl//libs//TSCLIB.dll" try: tsclibrary = ctypes.WinDLL(WinDll_path) tsclibrary.openportW("USB") print(zpl_str) tsclibrary.sendcommandW(zpl_str) print('111222') tsclibrary.printlabelW("0", "1"); tsclibrary.closeport(); except Exception as e: raise UserWarning("错误警告:%s" % e)