[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 <IT-Ideas@users.noreply.github.com>
This commit is contained in:
Thibault Libioulle
2021-06-24 13:05:41 +00:00
parent bdd0491fb2
commit caa58cdc46
@@ -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')
)