Odoo Help
Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM
|
e-Commerce
|
Accounting
|
Inventory
|
PoS
|
Project management
|
MRP
|
etc.
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.
About This Community
This platform 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.
RegisterOdoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.
Test it nowQuestion tools
Stats
Asked: 1/22/15, 5:53 AM |
Seen: 2303 times |
Last updated: 3/16/15, 8:10 AM |
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, I want to show the actual total value and total rounded value on pos receipt.