Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

How to print rounding adjustment value on point of sale receipt?

By
JC
on 1/22/15, 5:53 AM 1,676 views

Is there a way to print rounding adjustment on receipt?

Not sure if I understood your question, but do you mean that you want to show the actual value and also the rounded value? For rounding, you can try using t-esc="round(total,2)" - which will round to two decimal places.

Shawn Varghese
on 1/25/15, 12:01 AM

Shawn, I want to show the actual total value and total rounded value on pos receipt.

JC
on 1/25/15, 9:11 PM
1
Shawn Varghese
On 1/26/15, 2:12 AM

In the pos.xml file at the path: /point_of_sale/static/src/xml,

there is the PosTicket template which creates the receipt.

The total is displayed in this code:

<t t-esc="widget.format_currency(order.getTotalTaxIncluded())"/>

The format_currency() function actual takes 2 arguments - amount and precision. So if you call the function as

<t t-esc="widget.format_currency(order.getTotalTaxIncluded(),1)"/>

it should have rounded to 1 decimal place. However, it seems if you have specified a decimal precision for your currency (as is probably the case), it will take only that. But the above line did output a whole number, without any decimal places.

I tried using the “round” function, but that also did not work for me.

I suggest creating a separate function, in widgets_base.js similar to the format_currency() function:

format_currency_round: function(amount,precision){

var currency = (this.pos && this.pos.currency) ? this.pos.currency : {symbol:'$', position: 'after', rounding: 0.01, decimals: 2};

var decimals = precision;

if (typeof amount === 'number') {

amount = round_di(amount,decimals).toFixed(decimals);

}

if (currency.position === 'after') {

return amount + ' ' + (currency.symbol || '');

}

else {

return (currency.symbol || '') + ' ' + amount;

}

},
 

and call it from pos.xml as:

<tr class="emph">

<td>Rounded Total:</td>

<td class="pos-right-align">

<span t-esc="widget.format_currency_round(order.getTotalTaxIncluded(),1)"></span>

</td>

</tr>

 

This should give you the Total rounded to one decimal place.

Hope this helps.

Thanks Shawn, voted for you.

JC
on 1/26/15, 9:23 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 1/22/15, 5:53 AM
Seen: 1676 times
Last updated: 3/16/15, 8:10 AM