From 07e6cc73c179fc6664d281f7fb6aad8cf7bc7301 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 26 Jun 2019 14:10:48 +0000 Subject: [PATCH] [FIX] sale: sales_to_invoice_count in Sales Channel The count sales_to_invoice_count was wrong due to the domain wrote in function _compute_sales_to_invoice. Using 'order_line.qty_to_invoice' in the domain included duplicate orders in the read_group on 'sale.order' because there is auto_join=True on the field order_line. opw:2009808 closes odoo/odoo#34391 Signed-off-by: Simon Goffin (sig) --- addons/sale/models/sales_team.py | 2 +- addons/sale/views/sale_views.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/sale/models/sales_team.py b/addons/sale/models/sales_team.py index 78e6773fa8c..ff240412171 100644 --- a/addons/sale/models/sales_team.py +++ b/addons/sale/models/sales_team.py @@ -51,7 +51,7 @@ class CrmTeam(models.Model): def _compute_sales_to_invoice(self): sale_order_data = self.env['sale.order'].read_group([ ('team_id', 'in', self.ids), - ('order_line.qty_to_invoice', '>', 0), + ('invoice_status','=','to invoice'), ], ['team_id'], ['team_id']) for datum in sale_order_data: self.browse(datum['team_id'][0]).sales_to_invoice_count = datum['team_id_count'] diff --git a/addons/sale/views/sale_views.xml b/addons/sale/views/sale_views.xml index 3826b82831c..6648577c013 100644 --- a/addons/sale/views/sale_views.xml +++ b/addons/sale/views/sale_views.xml @@ -852,7 +852,7 @@ form tree,form,calendar,graph,kanban,pivot - [('state', '=', 'sale'),('invoice_status','=','to invoice')] + [('invoice_status','=','to invoice')] { 'search_default_team_id': [active_id], 'default_team_id': active_id,