Skip to content
Snippets Groups Projects
Commit f3ac28cf authored by nda-odoo's avatar nda-odoo
Browse files

[FIX] sale_management: fix wrong kpi_sale_total_value calculation


backport of 4ff2d0ad

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-3116707

closes odoo/odoo#111225

Signed-off-by: default avatarVictor Feyens (vfe) <vfe@odoo.com>
parent f740cbee
Branches
Tags
No related merge requests found
......@@ -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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment