From caa58cdc463ab1b9acd3da5e3a6ad35e9bc774be Mon Sep 17 00:00:00 2001 From: Thibault Libioulle Date: Wed, 23 Jun 2021 12:27:17 +0000 Subject: [PATCH] [FIX] sale_timesheet: fix wrong join condition Prior to this commit, the account move line was not correctly joined, and put in relation with SOL. Furthermore, this table isn't use. In this commit we correctly join the subquery, in this subquery, we just try to avoid to take into account amounts that are related to invoiced sale order lines. closes odoo/odoo#72710 X-original-commit: b04465d3514fe5cd52b7994962fe4069933ae6fd Signed-off-by: LTU-Odoo --- .../report/project_profitability_report_analysis.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/sale_timesheet/report/project_profitability_report_analysis.py b/addons/sale_timesheet/report/project_profitability_report_analysis.py index c98babbcf76..8e9c1ab4703 100644 --- a/addons/sale_timesheet/report/project_profitability_report_analysis.py +++ b/addons/sale_timesheet/report/project_profitability_report_analysis.py @@ -184,8 +184,7 @@ class ProfitabilityAnalysis(models.Model): AND NOT EXISTS ( SELECT SOL.id FROM sale_order_line SOL - JOIN sale_order_line_invoice_rel SOINV ON SOINV.order_line_id = SOL.id - JOIN account_move_line AML ON SOINV.invoice_line_id = AAL.move_id + JOIN sale_order_line_invoice_rel SOINV ON SOINV.order_line_id = SOL.id AND SOINV.invoice_line_id = AAL.move_id -- AAL.move_id is an account.move.line id WHERE SOL.qty_delivered_method IN ('timesheet', 'manual') OR (SOL.qty_delivered_method = 'analytic' AND SOL.invoice_status != 'no') )