[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) <nim@odoo.com>
This commit is contained in:
Nicolas Martinelli
2020-11-19 14:14:48 +00:00
parent d060eb9063
commit 7def913f24
@@ -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):