活动现场最怕的不是打印机坏,而是“谁都能打 badge”“打了 badge 却没售出”“设备联通了但状态回不到活动系统”。Odoo 企业版用 event_iot、event_sale_iot 与 iot 把签到、打印和销售资格连成一条现场闭环。
## 1. 活动注册记录会先暴露可用 IoT 打印机,而不是直接打印
在 enterprise/event_iot/models/event_registration.py,当活动采用 badge printer 格式时,注册记录会搜索 subtype 为 label_printer 的 IoT 设备,并把 printer 元数据一并返回给前端对话框。这里先传的是设备能力与标识,不是直接吐打印命令。
2. 打印报表会把 event registration 上下文翻译成设备可执行模板
report/event_registration_badge_printer_report.py 与模板 event_iot_templates.xml 负责把活动 logo、票种颜色、姓名等字段渲染成打印机可接受的格式,再交给 IoT 报表动作。也就是说,Event 负责业务数据,IoT 负责设备通道,中间由报表层完成协议翻译。
3. Sale 桥接模块负责阻止“未售出即自动打印”
event_sale_iot 的 manifest 直接写明:其唯一目标之一是防止 registration 尚未 sold 时自动打印。这个约束很关键,它说明现场打印资格并不只看 event registration 是否存在,还要看销售侧是否已确认。
4. IoT 通道保证打印动作真的是设备级调用
底层 enterprise/iot/models/ir_actions_report.py 与 iot.channel.py 会把待打印文档和设备标识发送到 IoT Box。这样系统知道“哪台设备执行了哪张 badge”,现场动作不会沦为浏览器本地打印的黑盒。
## 结论
所以,Odoo 企业版活动现场的 badge 打印不是“签到后顺手出一张纸”,而是 Event 提供对象、Sale 提供资格、IoT 提供设备执行与回路的三段式链条。
主要源码锚点:
- `enterprise/event_iot/models/event_registration.py`
enterprise/event_iot/report/event_registration_badge_printer_report.pyenterprise/event_iot/report/event_iot_templates.xmlenterprise/event_sale_iot/__manifest__.pyenterprise/iot/models/ir_actions_report.py
DISCUSSION
评论区