From 793160351322dfe962f659ec2d837fb7633efcec Mon Sep 17 00:00:00 2001 From: Victor Feyens Date: Thu, 1 Feb 2024 11:39:10 +0000 Subject: [PATCH] [FIX] sale: sales analysis discount Summing discount percentages doesn't mean anything. This commit makes sure the operator used to compute discount on group of records is 'average'. It won't always be meaningful, but in some cases, e.g. when the solines only hold one product, and the lines are grouped by product. opw-3649377 closes odoo/odoo#152455 X-original-commit: bf4aa3fdfcb6b2b3a5b4411130321e154fa098aa Signed-off-by: Victor Feyens (vfe) --- addons/sale/report/sale_report.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/sale/report/sale_report.py b/addons/sale/report/sale_report.py index 9f54f2d66e5..ecd6217f8a0 100644 --- a/addons/sale/report/sale_report.py +++ b/addons/sale/report/sale_report.py @@ -1,7 +1,7 @@ -# -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, fields, models, tools +from odoo import api, fields, models + from odoo.addons.sale.models.sale_order import SALE_ORDER_STATE @@ -72,7 +72,7 @@ class SaleReport(models.Model): weight = fields.Float(string="Gross Weight", readonly=True) volume = fields.Float(string="Volume", readonly=True) - discount = fields.Float(string="Discount %", readonly=True) + discount = fields.Float(string="Discount %", readonly=True, group_operator='avg') discount_amount = fields.Monetary(string="Discount Amount", readonly=True) # aggregates or computed fields