From 7def913f2430ffc2c0a74edbecabb131b995e5d8 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 18 Nov 2020 13:07:16 +0000 Subject: [PATCH] [FIX] point_of_sale: rounding in report - Create a product with price 2335.5, no tax - Start a POS session - Add the product, set a discount of 3% on the line => total is 2665.44 - Validate and close the session - Got to Point of Sale / Reporting / Orders, open the pivot view The Total Price of the order is 2665.43. It happens because the server returns a value of 2665.435, which is displayed in the pivot view as 2665.43. We round the Total Price based on the company currency decimal precision. Indeed, all amounts are converted in this currency in the report. opw-2369023 closes odoo/odoo#62023 X-original-commit: 178d5c879ccf7ed59e602f049377417ace353fa9 Signed-off-by: Nicolas Martinelli (nim) --- addons/point_of_sale/report/pos_order_report.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/report/pos_order_report.py b/addons/point_of_sale/report/pos_order_report.py index 21eb73d8510..95a69f79adb 100644 --- a/addons/point_of_sale/report/pos_order_report.py +++ b/addons/point_of_sale/report/pos_order_report.py @@ -44,7 +44,7 @@ class PosOrderReport(models.Model): s.date_order AS date, SUM(l.qty) AS product_qty, SUM(l.qty * l.price_unit / CASE COALESCE(s.currency_rate, 0) WHEN 0 THEN 1.0 ELSE s.currency_rate END) AS price_sub_total, - SUM((l.qty * l.price_unit) * (100 - l.discount) / 100 / CASE COALESCE(s.currency_rate, 0) WHEN 0 THEN 1.0 ELSE s.currency_rate END) AS price_total, + SUM(ROUND((l.qty * l.price_unit) * (100 - l.discount) / 100 / CASE COALESCE(s.currency_rate, 0) WHEN 0 THEN 1.0 ELSE s.currency_rate END, cu.decimal_places)) AS price_total, SUM((l.qty * l.price_unit) * (l.discount / 100) / CASE COALESCE(s.currency_rate, 0) WHEN 0 THEN 1.0 ELSE s.currency_rate END) AS total_discount, (SUM(l.qty*l.price_unit / CASE COALESCE(s.currency_rate, 0) WHEN 0 THEN 1.0 ELSE s.currency_rate END)/SUM(l.qty * u.factor))::decimal AS average_price, SUM(cast(to_char(date_trunc('day',s.date_order) - date_trunc('day',s.create_date),'DD') AS INT)) AS delay_validation, @@ -72,6 +72,8 @@ class PosOrderReport(models.Model): LEFT JOIN product_template pt ON (p.product_tmpl_id=pt.id) LEFT JOIN uom_uom u ON (u.id=pt.uom_id) LEFT JOIN pos_session ps ON (s.session_id=ps.id) + LEFT JOIN res_company co ON (s.company_id=co.id) + LEFT JOIN res_currency cu ON (co.currency_id=cu.id) """ def _group_by(self):