From 09792602e874fadc7a28f2785a8c32a0858f1a9a Mon Sep 17 00:00:00 2001 From: Demesmaeker <edm@odoo.com> Date: Fri, 21 Apr 2023 09:46:43 +0000 Subject: [PATCH] [FIX] sale_margin: correct computation of margin in groupby in the SO For now, the sale margin is incorrectly computed in group by in the sales order. This was done in the sales order lines in abdb85fb28af097824d7c18b8feb82af508608eb opw-3180556 closes odoo/odoo#119333 Signed-off-by: Morgane Demesmaeker <edm@odoo.com> --- addons/sale_margin/models/sale_order.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/sale_margin/models/sale_order.py b/addons/sale_margin/models/sale_order.py index 49104b4cfe32..73c8fced5d43 100644 --- a/addons/sale_margin/models/sale_order.py +++ b/addons/sale_margin/models/sale_order.py @@ -60,7 +60,9 @@ class SaleOrder(models.Model): _inherit = "sale.order" margin = fields.Monetary("Margin", compute='_compute_margin', store=True) - margin_percent = fields.Float("Margin (%)", compute='_compute_margin', store=True) + margin_percent = fields.Float( + "Margin (%)", compute='_compute_margin', store=True, group_operator='avg' + ) @api.depends('order_line.margin', 'amount_untaxed') def _compute_margin(self): -- GitLab