I need to modify the receipt of Point of sale
In Odoo point of sale, the are two templates to print receipt : XmlReceipt and PosTicket
As I use a Posbox I guess I have to modify XmlReceipt. I wonder if there is a way to inherit the original template ? I found examples on how to do it with PosTicket template but Xmlreceipt doesnt seem to work the same way.
Any ideas ?
Thank you.
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>
来源:https://stackoverflow.com/questions/33459989/odoo-point-of-sale-posbox-how-to-modify-receipt