From 37f09f61e0d283d85069dfd6634e95ff3ff99989 Mon Sep 17 00:00:00 2001 From: roen-odoo Date: Mon, 22 Apr 2024 17:17:44 +0200 Subject: [PATCH] [FIX] point_of_sale: pos sale reprot total now include taxes correctly Current behavior: If you make a sale of a product that use a taxe not included in the price. Then go in order analysis in PoS, the total price of the product will not include the taxes. Steps to reproduce: - Create a tax of 15% that is not included in price - Create a product with 10$ price and add this tax to it. (Total price including tax should be 11.5$) - Sell it in the PoS and close the session - Go in PoS > Reporting > Order. Open the pivot view and check the total price for the product - The total is 10$ instad of 11.5$ opw-3817535 closes odoo/odoo#163239 X-original-commit: 42fd6a65c8910bff587b6bc55d49e1bafb165487 Signed-off-by: Vlad Stroia (vlst) Signed-off-by: Robin Engels (roen) --- addons/point_of_sale/report/pos_order_report.py | 2 +- addons/point_of_sale/tests/test_report_pos_order.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/addons/point_of_sale/report/pos_order_report.py b/addons/point_of_sale/report/pos_order_report.py index 4321e037366..0d791effebc 100644 --- a/addons/point_of_sale/report/pos_order_report.py +++ b/addons/point_of_sale/report/pos_order_report.py @@ -45,7 +45,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(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(ROUND((l.price_subtotal_incl) * (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, CASE WHEN SUM(l.qty * u.factor) = 0 THEN NULL diff --git a/addons/point_of_sale/tests/test_report_pos_order.py b/addons/point_of_sale/tests/test_report_pos_order.py index 0aa069129f6..6c6ae5a4451 100644 --- a/addons/point_of_sale/tests/test_report_pos_order.py +++ b/addons/point_of_sale/tests/test_report_pos_order.py @@ -13,7 +13,7 @@ class TestReportPoSOrder(TestPoSCommon): def test_report_pos_order(self): - product1 = self.create_product('Product 1', self.categ_basic, 150) + product1 = self.create_product('Product 1', self.categ_basic, 150, self.taxes['tax10'].id) self.open_new_session() session = self.pos_session @@ -27,10 +27,10 @@ class TestReportPoSOrder(TestPoSCommon): 'discount': 0, 'qty': 1.0, 'price_subtotal': 150, - 'price_subtotal_incl': 150, + 'price_subtotal_incl': 165, }),], - 'amount_total': 150.0, - 'amount_tax': 0.0, + 'amount_total': 165.0, + 'amount_tax': 15.0, 'amount_paid': 0.0, 'amount_return': 0.0, }) @@ -39,3 +39,4 @@ class TestReportPoSOrder(TestPoSCommon): reports = self.env['report.pos.order'].sudo().search([('product_id', '=', product1.id)], order='id') self.assertEqual(reports[0].margin, 150) + self.assertEqual(reports[0].price_total, 165)