Help

0

How to add a new field value in POS Receipt (OrderReceipt) template

Avatar
Gopakumar N G

How to add new field values in the Pos Receipt(both new fields and existing fields in Odoo product table). In the following receipt template


<t t-name="OrderReceipt">
<div class="pos-receipt">
<t t-if='receipt.company.logo'>
<img class="pos-receipt-logo" t-att-src='receipt.company.logo' alt="Logo"/>
<br/>
</t>
<t t-if='!receipt.company.logo'>
<h2 class="pos-receipt-center-align">
<t t-esc='receipt.company.name' />
</h2>
<br/>
</t>
<div class="pos-receipt-contact">
<t t-if='receipt.company.contact_address'>
<div><t t-esc='receipt.company.contact_address' /></div>
</t>
<t t-if='receipt.company.phone'>
<div>Tel:<t t-esc='receipt.company.phone' /></div>
</t>
<t t-if='receipt.company.vat'>
<div>VAT:<t t-esc='receipt.company.vat' /></div>
</t>
<t t-if='receipt.company.email'>
<div><t t-esc='receipt.company.email' /></div>
</t>
<t t-if='receipt.company.website'>
<div><t t-esc='receipt.company.website' /></div>
</t>
<t t-if='receipt.header_html'>
<t t-raw='receipt.header_html' />
</t>
<t t-if='!receipt.header_html and receipt.header'>
<div><t t-esc='receipt.header' /></div>
</t>
<t t-if='receipt.cashier'>
<div class='cashier'>
<div>--------------------------------</div>
<div>Served by <t t-esc='receipt.cashier' /></div>
</div>
</t>
</div>
<br /><br />

<!-- Orderlines -->

<div class='orderlines'>
<t t-foreach='receipt.orderlines' t-as='line'>
<t t-set='simple' t-value='(line.discount === 0 and line.unit_name === "Units" and line.quantity === 1 and !discount_to_show and !(line.display_discount_policy == "without_discount" &amp;&amp; line.price != line.price_lst))' />
<t t-if='simple'>
<div><t t-esc='line.product_name_wrapped[0]' /><span t-esc='widget.format_currency_no_symbol(line.price_display)' class="price_display pos-receipt-right-align"/></div><t t-call="OrderReceiptWrappedProductNameLines"/></t>
<t t-if='!simple'>
<div t-esc='line.product_name_wrapped[0]'/><t t-call="OrderReceiptWrappedProductNameLines"/><t t-if="line.display_discount_policy == 'without_discount' &amp;&amp; line.price != line.price_lst"><div class="pos-receipt-left-padding"><t t-esc="widget.format_currency_no_symbol(line.price_lst)" />-><t t-esc="widget.format_currency_no_symbol(line.price)" /></div>
</t>
<t t-elif='line.discount !== 0'>
<div class="pos-receipt-left-padding">
<t t-if="pos.config.iface_tax_included === 'total'">
<t t-esc="widget.format_currency_no_symbol(line.price_with_tax_before_discount)"/>
</t>
<t t-else="">
<t t-esc="widget.format_currency_no_symbol(line.price)"/>
</t>
</div>
</t>
<t t-if='line.discount !== 0'>
<div class="pos-receipt-left-padding">
Discount: <t t-esc='line.discount' />%
</div>
</t>
<div class="pos-receipt-left-padding">
<t t-esc="Math.round(line.quantity * Math.pow(10, pos.dp['Product Unit of Measure'])) / Math.pow(10, pos.dp['Product Unit of Measure'])"/>
<t t-if='line.unit_name !== "Units"' t-esc='line.unit_name'/>
x
<t t-esc='widget.format_currency_no_symbol(line.price_display_one)' />
<span class="price_display pos-receipt-right-align">
<t t-esc='widget.format_currency_no_symbol(line.price_display)'/>
</span>
</div>
</t>
</t>
</div>

<!-- Subtotal -->

<t t-set='taxincluded' t-value='Math.abs(receipt.subtotal - receipt.total_with_tax) &lt;= 0.000001' />
<t t-if='!taxincluded'>
<div class="pos-receipt-right-align">--------</div>
<br/>
<div>Subtotal<span t-esc='widget.format_currency(receipt.subtotal)' class="pos-receipt-right-align"/></div>
<t t-foreach='receipt.tax_details' t-as='tax'>
<div>
<t t-esc='tax.name' />
<span t-esc='widget.format_currency_no_symbol(tax.amount)' class="pos-receipt-right-align"/>
</div>
</t>
</t>

<!-- Total -->
<div class="pos-receipt-right-align">--------</div>
<br/>
<div class="pos-receipt-amount">
TOTAL
<span t-esc='widget.format_currency(receipt.total_with_tax)' class="pos-receipt-right-align"/>
</div>
<br/><br/>

<!-- Payment Lines -->

<t t-foreach='paymentlines' t-as='line'>
<div>
<t t-esc='line.name' />
<span t-esc='widget.format_currency_no_symbol(line.get_amount())' class="pos-receipt-right-align"/>
</div>
</t>
<br/>

<div class="pos-receipt-amount receipt-change">
CHANGE
<span t-esc='widget.format_currency(receipt.change)' class="pos-receipt-right-align"/>
</div>
<br/>

<!-- Extra Payment Info -->

<t t-if='receipt.total_discount'>
<div>
Discounts
<span t-esc='widget.format_currency(receipt.total_discount)' class="pos-receipt-right-align"/>
</div>
</t>
<t t-if='taxincluded'>
<t t-foreach='receipt.tax_details' t-as='tax'>
<div>
<t t-esc='tax.name' />
<span t-esc='widget.format_currency_no_symbol(tax.amount)' class="pos-receipt-right-align"/>
</div>
</t>
<div>
Total Taxes
<span t-esc='widget.format_currency(receipt.total_tax)' class="pos-receipt-right-align"/>
</div>
</t>

<div class='before-footer' />

<!-- Footer -->
<div t-if='receipt.footer_html' class="pos-receipt-center-align">
<t t-raw='receipt.footer_html'/>
</div>

<div t-if='!receipt.footer_html and receipt.footer' class="pos-receipt-center-align">
<br/>
<t t-esc='receipt.footer'/>
<br/>
<br/>
</div>

<div class='after-footer'>
<t t-foreach='paymentlines' t-as='line'>
<t t-if='line.ticket'>
<br />
<div class="pos-payment-terminal-receipt">
<t t-raw='line.ticket'/>
</div>
</t>
</t>
</div>

<br/>
<div class="pos-receipt-order-data">
<div><t t-esc='receipt.name' /></div>
<div><t t-esc='receipt.date.localestring' /></div>
</div>

</div>
</t>
Avatar
Negeren
1 Antwoord
0
Avatar
Prakash
Beste antwoord
t-extend OrderReceipt template and add new field.

Default core module "pos_cash_rounding"  used, sample code

<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-extend="OrderReceipt">
<t t-jquery='.pos-receipt-amount:first' t-operation='after'>
<t t-if="receipt.total_rounded != receipt.total_with_tax">
<div class="pos-receipt-amount">
ROUNDED
<span t-esc='widget.format_currency(receipt.total_rounded)' class="pos-receipt-right-align"/>
</div>
</t>
</t>
</t>
<t t-extend="PaymentScreen-Paymentlines">
<t t-jquery='.paymentlines-empty > .total' t-operation='replace'>
<div class='total'>
<t t-esc="widget.format_currency(order.get_total_with_tax() + order.get_rounding_applied())"/>
</div>
</t>
</t>
</templates>
Avatar
Negeren