From fd560917abfd647535797462e59cbb155bc98ea0 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Wed, 6 Dec 2017 15:25:45 +0100 Subject: [PATCH] [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 --- addons/point_of_sale/models/pos_order.py | 1 + addons/point_of_sale/static/src/js/devices.js | 2 ++ addons/point_of_sale/static/src/xml/pos.xml | 6 +++--- addons/point_of_sale/views/report_saledetails.xml | 6 +++--- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index 044a98bb721..1f1cdcc328d 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -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, diff --git a/addons/point_of_sale/static/src/js/devices.js b/addons/point_of_sale/static/src/js/devices.js index 5d272bbfda8..e8bd95bc117 100644 --- a/addons/point_of_sale/static/src/js/devices.js +++ b/addons/point_of_sale/static/src/js/devices.js @@ -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, diff --git a/addons/point_of_sale/static/src/xml/pos.xml b/addons/point_of_sale/static/src/xml/pos.xml index ee5bef3456d..c6627159262 100644 --- a/addons/point_of_sale/static/src/xml/pos.xml +++ b/addons/point_of_sale/static/src/xml/pos.xml @@ -900,7 +900,7 @@ - + @@ -914,7 +914,7 @@ - + @@ -925,7 +925,7 @@ Total: - + diff --git a/addons/point_of_sale/views/report_saledetails.xml b/addons/point_of_sale/views/report_saledetails.xml index c7cb58c6c4f..805f5808dd8 100644 --- a/addons/point_of_sale/views/report_saledetails.xml +++ b/addons/point_of_sale/views/report_saledetails.xml @@ -50,7 +50,7 @@ - + @@ -66,7 +66,7 @@ - + @@ -74,7 +74,7 @@

- Total: + Total: