【问题标题】:Print Bacode on Odoo Pos Receipt在 Odoo Pos 收据中打印条形码
【发布时间】:2017-07-10 12:04:30
【问题描述】:
我正在执行 Odoo 8,并且有客户的要求,将 Pos Receipt 参考打印为收据底部的条形码。
我设法通过以下方式打印了一个样本:
- 下载barcode-jquery插件,解压到point_of_sale/static/src/js/下
- 使用以下代码创建名为barcode.js 的JS 文件
$("#bcTarget").barcode("1234567890123", "ean13");
- 在 pos.xml 中的 PosTicket 模板下添加了以下行
<div id="bcTarget"></div><br />
<xpath expr="." position="inside">
<script type="text/javascript" src="/point_of_sale/static/src/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="/point_of_sale/static/src/js/jquery-barcode.js"></script>
<script type="text/javascript" src="/point_of_sale/static/src/js/barcode.js" />
</xpath>
但是我的问题是我没有设法将 orde.pos_reference 打印为条形码本身,请问有什么想法吗?
提前致谢
【问题讨论】:
标签:
javascript
jquery
python
xml
odoo-8
【解决方案1】:
您使用条形码的情况是,您需要扩展客户端 qweb 模板和小部件,以便 POS 能够添加该行为。在 Odoo JS 框架中,代码的工作原理不是问题,更多的是关于将工作的代码放在哪里以及如何正确扩展 Odoo 小部件
您可以从模块中的这个 js 开始(例如 pos_barcode_module):
openerp.pos_barcode_module = function (instance) {
var _t = instance.web._t;
var QWeb = instance.web.qweb;
var session = instance.session;
var ReceiptScreenWidget = instance.point_of_sale.ReceiptScreenWidget;
ReceiptScreenWidget.include({
refresh: function() {
var order = this.pos.get('selectedOrder');
//get the needed reference or references for the products or the order itself
this._super();
//apply js transformations to:
//$('.pos-receipt-container', this.$el)
}
});
};
也许您还需要扩展客户端 qweb 模板 PosTicket 以添加条形码的 html 节点容器
这只是使用过的 POS 票证之一,可能需要处理 Odoo POS 的打印代理,它不会是相同的小部件/模板
或者你两者都需要它......
这并不像看起来那么容易
我的两分钱
【解决方案2】:
您只需在 xml 模板中添加这么多代码:
<t t-if='receipt.barcode'>
<barcode encoding="EAN13"><t t-esc="receipt.barcode"/></barcode>
<br/>
</t>
收据上有条码..