From 6f93f7bc635cbe709b53310c2b48476711f5c2de Mon Sep 17 00:00:00 2001 From: krha-odoo Date: Fri, 7 Oct 2022 14:29:58 +0000 Subject: [PATCH] [FIX] sale_management: fix wrong kpi_sale_total_value calculation Before this commit, if two or more lines in sale_report had the same value as price_total, they were group together in _compute_kpi_sale_total_value and included in output sum only once. That leads to incorrect values in digest mail. This commit fixes that issue by changing grouping column from price_total to company_id. Steps to reproduce the issue: ---------------------------- 1. Send Digest Mail for database and check values in it (assume we have both All Sales KPI and PoS KPI). 2. Create several sale_order_line and/or pos_order_line with exactly the same price_total (for example: 5 PoS transaction, each one for one product of value 10000). 2. Send Digest Mail again and check values in it. Current behavior: ----------------- The All Sales KPI will increase by value of only one of lines (in our example: PoS KPI will increase by 50000 = 5*10000, All Sales KPI will increase by 10000) Expected behavior: ----------------- All Sales KPI should include all transactions from sale_report in given period of time (all sale_order_line and pos_order_line). opw-2938952 closes odoo/odoo#105248 X-original-commit: 804c485f6afe98c5d63cfe91ce65e0a8352fc92e Signed-off-by: Victor Feyens (vfe) --- addons/sale_management/models/digest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale_management/models/digest.py b/addons/sale_management/models/digest.py index 7782cb765db..ba577ff5b87 100644 --- a/addons/sale_management/models/digest.py +++ b/addons/sale_management/models/digest.py @@ -20,7 +20,7 @@ class Digest(models.Model): ('date', '>=', start), ('date', '<', end), ('state', 'not in', ['draft', 'cancel', 'sent']), - ('company_id', '=', company.id)], ['price_total'], ['price_total']) + ('company_id', '=', company.id)], ['price_total'], ['company_id']) record.kpi_all_sale_total_value = sum([channel_sale['price_total'] for channel_sale in all_channels_sales]) def _compute_kpis_actions(self, company, user):