PrintBase
  • Product
  • Pricing
  • Docs
  • Resources
PrintBase/专题/平台打印接入

Odoo 如何打印斑马标签而不用 IoT Box

在 Odoo 服务端动作里把 ZPL 发给仓库电脑上的斑马打印机。不安装 IoT Box,也没有官方 Odoo 模块。调用 POST /v1/print-jobs,API Key 只放在服务端。

面向 已经有仓库电脑和斑马打印机的 Odoo 用户

其他语言版本: English

说明

Odoo 的 IoT Box 是到达打印机的一种办法。仓库里如果已经有一台能看到斑马打印机的电脑,就可以在那台电脑上跑 Agent,由 Odoo 服务器直接 POST ZPL。本产品不提供 Odoo 应用商店模块,也不配置 IoT Box。

在服务端动作或自定义模块里生成 ^XA 到 ^XZ。203 dpi 的 4×6 英寸大约是 812×1218 点,300 dpi 要按点重算。content_type 使用 raw。printer_code 按仓库保存。

Idempotency-Key 用拣货单号加标签序号。API Key 放在系统参数,不要放进浏览器能看到的 QWeb 模板。

创建任务使用 POST /v1/print-jobs,请求头 Authorization: Bearer,正文包含 printer_code、content_type(pdf 或 raw)以及 content 或 content_url 二者之一。免费套餐是一台电脑每月 100 个任务。

创建任务使用 POST /v1/print-jobs,请求头 Authorization: Bearer,正文包含 printer_code、content_type(pdf 或 raw)以及 content 或 content_url 二者之一。免费套餐是一台电脑每月 100 个任务。

接入步骤

  1. 01

    仓库电脑安装 Agent

    先用系统测试页确认斑马队列正常,再查 code。请求使用 POST /v1/print-jobs,请求头为 Authorization: Bearer,printer_code 来自 GET /v1/printers。

  2. 02

    在 Odoo 里生成 ZPL

    条码用 ^BC 或 ^BQ,不要把条码画成图片再包进 PDF,除非你决定走 pdf。请求使用 POST /v1/print-jobs,请求头为 Authorization: Bearer,printer_code 来自 GET /v1/printers。

  3. 03

    服务器发起 POST

    不要从网站访客的浏览器调用。请求使用 POST /v1/print-jobs,请求头为 Authorization: Bearer,printer_code 来自 GET /v1/printers。

  4. 04

    按仓库映射打印机

    接口没有 Odoo 库位对象,映射表写在你的模块里。请求使用 POST /v1/print-jobs,请求头为 Authorization: Bearer,printer_code 来自 GET /v1/printers。

  5. 05

    把任务号记到拣货单

    方便现场看到 AGENT_OFFLINE 而不是只看 Odoo 日志。请求使用 POST /v1/print-jobs,请求头为 Authorization: Bearer,printer_code 来自 GET /v1/printers。

Python

# Odoo 服务端:ZPL 标签
import json, os, urllib.request

body = json.dumps({
    "printer_code": int(os.environ["PRINTER_CODE"]),
    "content_type": "raw",
    "content": base64.b64encode(zpl.encode()).decode(),,
    "copies": 1,
}).encode()

req = urllib.request.Request(
    "https://api.printbase.cloud/v1/print-jobs",
    data=body,
    method="POST",
    headers={
        "Authorization": f"Bearer {os.environ['PRINTBASE_API_KEY']}",
        "Content-Type": "application/json",
        "Idempotency-Key": picking.name,
    },
)
with urllib.request.urlopen(req) as res:
    job = json.load(res)  # {"id": "job_abc", "status": "queued"}

这一套的细节

IoT Box 可以留着

这页不要求拆掉现有 IoT。只让 Agent 负责它旁边的那台打印机。Agent 只打印你提交的内容,不会替你向平台拉取单据。Agent 只打印你提交的内容,不会替你向平台拉取单据。

怎样确认已经打出来

创建接口返回 id 和 status queued。之后是 queued、dispatched、printing、completed。失败原因包括 AGENT_OFFLINE、PRINTER_OFFLINE、DOWNLOAD_FAILED、PRINT_ERROR、INVALID_CONTENT。用 GET /v1/print-jobs/{id} 查询。Webhook 只在付费套餐提供,且只有 print_job.completed 和 print_job.failed。

常见问题

有官方 Odoo 模块吗?

没有。用服务端动作或很短的自定义模块即可。调用的仍是 POST /v1/print-jobs,请求头为 Bearer API Key。HTTP 201 只表示已排队,不表示已经出纸。

交货单 PDF 呢?(详见本页)

PDF 用 content_type pdf,不要标成 raw。英文页 odoo-delivery-slips 写的是 PDF 交货单。

标签缩小了?(详见本页)

点阵和 dpi 不匹配。按打印头重新计算 ^PW 和 ^LL。调用的仍是 POST /v1/print-jobs,请求头为 Bearer API Key。HTTP 201 只表示已排队,不表示已经出纸。

需要开放 9100 端口吗?

不需要公网端口。Agent 把 raw 送进系统队列。调用的仍是 POST /v1/print-jobs,请求头为 Bearer API Key。HTTP 201 只表示已排队,不表示已经出纸。

相关页面

  • 斑马 ZD888 远程打印 ZPL 快递面单

    把 ZPL 发到斑马 ZD888。按机身配置页上的 dpi 计算点阵。Agent 打到系统队列,不需要打印机公网 IP。调用 POST /v1/print-jobs,API Key 只放在服务端。

  • 用 Spring Boot 打印小票

    在 Spring Boot 服务里用 RestClient 把 ESC/POS 小票 POST 到打印接口,由门店电脑上的 Agent 打到本地小票机。API Key 放在配置里,不作为请求参数。

免费套餐:一台电脑每月 100 个任务,不需要信用卡。

免费注册查看 API 文档
PrintBase

PrintBase connects your applications to physical printers anywhere - securely, reliably, and in real time.

Product
Receipt PrintingLabel PrintingDashboardDevicesWebhooks
Resources
DocsBlogStatusAPI ReferenceDownloadPrintBase vs PrintNodePrintNode PricingFAQ
Guides
All guidesIntegrationsPrintersCode samplesComparisonsUse casesTroubleshooting
Company
ContactSecurityPrivacy

© 2026 Aveniq Technologies OÜ. All rights reserved. PrintBase is a service of Aveniq Technologies OÜ.

PrivacyTermsRefunds