[FIX] point_of_sale: sale details report correctly renders float
Before this commit, when printing all orders from the POS interface, the ticket sometimes showed weird amounts (like 128.25000000001). This was due to the usual problem of representing a float and has nothing to do with Odoo. After this commit, the templates correctly display the amounts, rounded according to the currency We do this by applying the relevant qweb widget (or calling the right format function in JS) OPW 784626
This commit is contained in:
@@ -981,6 +981,7 @@ class ReportSaleDetails(models.AbstractModel):
|
||||
payments = []
|
||||
|
||||
return {
|
||||
'currency_precision': user_currency.digits,
|
||||
'total_paid': user_currency.round(total),
|
||||
'payments': payments,
|
||||
'company_name': self.env.user.company_id.name,
|
||||
|
||||
@@ -4,6 +4,7 @@ odoo.define('point_of_sale.devices', function (require) {
|
||||
var core = require('web.core');
|
||||
var Model = require('web.DataModel');
|
||||
var Session = require('web.Session');
|
||||
var PosBaseWidget = require('point_of_sale.BaseWidget');
|
||||
|
||||
var QWeb = core.qweb;
|
||||
var _t = core._t;
|
||||
@@ -440,6 +441,7 @@ var ProxyDevice = core.Class.extend(core.mixins.PropertiesMixin,{
|
||||
var self = this;
|
||||
new Model('report.point_of_sale.report_saledetails').call('get_sale_details').then(function(result){
|
||||
var env = {
|
||||
widget: new PosBaseWidget(self),
|
||||
company: self.pos.company,
|
||||
pos: self.pos,
|
||||
products: result.products,
|
||||
|
||||
@@ -900,7 +900,7 @@
|
||||
<line t-foreach='payments' t-as='payment'>
|
||||
<left><t t-esc='payment.name' /></left>
|
||||
<right>
|
||||
<t t-esc='payment.total'/>
|
||||
<t t-esc='widget.format_currency_no_symbol(payment.total)'/>
|
||||
</right>
|
||||
</line>
|
||||
|
||||
@@ -914,7 +914,7 @@
|
||||
<line t-foreach='taxes' t-as='taxe'>
|
||||
<left><t t-esc='taxe.name' /></left>
|
||||
<right>
|
||||
<t t-esc='taxe.total'/>
|
||||
<t t-esc='widget.format_currency_no_symbol(taxe.total)'/>
|
||||
</right>
|
||||
</line>
|
||||
|
||||
@@ -925,7 +925,7 @@
|
||||
<line>
|
||||
<left>Total:</left>
|
||||
<right>
|
||||
<t t-esc='total_paid'/>
|
||||
<t t-esc='widget.format_currency_no_symbol(total_paid)'/>
|
||||
</right>
|
||||
</line>
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
<tbody>
|
||||
<tr t-foreach='payments' t-as='payment'>
|
||||
<td><t t-esc="payment['name']" /></td>
|
||||
<td><t t-esc="payment['total']" /></td>
|
||||
<td><t t-esc="payment['total']" t-options="{'widget': 'float', 'precision': currency_precision}"/></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -66,7 +66,7 @@
|
||||
<tbody>
|
||||
<tr t-foreach='taxes' t-as='tax'>
|
||||
<td><t t-esc="tax['name']" /></td>
|
||||
<td><t t-esc="tax['total']" /></td>
|
||||
<td><t t-esc="tax['total']" t-options="{'widget': 'float', 'precision': currency_precision}"/></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -74,7 +74,7 @@
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<strong>Total: <t t-esc='total_paid'/></strong>
|
||||
<strong>Total: <t t-esc='total_paid' t-options="{'widget': 'float', 'precision': currency_precision}"/></strong>
|
||||
|
||||
</div>
|
||||
</t>
|
||||
|
||||
Reference in New Issue
Block a user