[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) <vfe@odoo.com>
This commit is contained in:
Victor Feyens
2024-02-03 06:59:48 +00:00
parent 4006e346f9
commit 7931603513
+3 -3
View File
@@ -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