How to do it...

Follow these steps to modify a customer receipt in the Point of Sale:

  1. Add the following code in the /static/src/js/pos_demo.js file. This will add extra data in the receipt environment:
var screens = require('point_of_sale.screens');

screens.ReceiptScreenWidget.include({
get_receipt_render_env: function () {
var receipt_env = this._super();
var order = this.pos.get_order();
var saved = 0;
_.each(order.orderlines.models, function (line) {
saved += ((line.product.list_price - line.get_base_price()) * line.quantity);
});
receipt_env['saved_amount'] = saved;
return receipt_env;
}
});
  1. Add the following code in /static/src/xml/pos_demo.xml. This will extend the default receipt template and add our customization:
 <t t-extend="PosTicket">
<t t-jquery=".receipt-change" t-operation="after">
<t t-if="saved_amount">
<br/>
<div class="pos-center-align">
<t t-esc="widget.format_currency(saved_amount)"/>
you saved in this order
</div>
</t>
</t>
</t>

Update the pos_demo module to apply the changes. After that, add a product with the discount and check the receipt; you will see one extra line in the receipt:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset