Odoo Point of Sale + Posbox : How to modify receipt

北慕城南 提交于 2019-12-01 13:37:57

I extends template "PosTicket", find element by t-jquery, replace with my data (Add "Free" to product's name)

<templates id="template" >
<t t-extend="PosTicket">
    <t t-jquery=".receipt-orderlines .product_line" t-operation="inner">
        <t t-if="orderline.get_reward() and orderline.get_reward().type == 'gift'">Free </t>
        <t t-esc="orderline.get_product().display_name"/>
    </t>
</t>

As far as I know XmlReceipt and PosTicket templates are both defined in pos.xml so you can inherit both of them in a same way. Example of inheriting XmlReceipt:

<?xml version="1.0" encoding="UTF-8"?>
<templates id="myReceiptTemplate" xml:space="preserve">
    <t t-extend="XmlReceipt">
        "your code here"
    </t>
</templates>

Ok, I found a solution. Example to print the unit price with tax included, I wrote my xml like this :

<?xml version="1.0" encoding="UTF-8"?>
<templates id="myReceiptTemplate" xml:space="preserve">
    <t t-extend="XmlReceipt">
         <t t-jquery="t[t-esc='line.price']" t-operation="replace">
            <t t-esc='line.price_with_tax / line.quantity ' />
        </t>      
    </t>
</templates>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!