From eb73917c0f61a8b52c56ea351c77bd941703e7aa Mon Sep 17 00:00:00 2001 From: "Victor Piryns (pivi)" Date: Thu, 23 Feb 2023 09:31:09 +0000 Subject: [PATCH] [FIX] sale_project: ignore down payments in project profitability Current behaviour: Down payments are taking into account in the project profitability in the section "Other Cost". When invoicing fully an SO, the total sum in profitability is the sum of the invoiced amount on the SO + the down payment. Expected behaviour: Down payments should not be present in the project profitability, to avoid incorrect sums. Steps to reproduce: - Install Sales, Accounting, Timesheets - Activate Analytics in the Settings - Set a Service Product that is invoiced based on fixed price - Make sure that it generates a Project + Task - Create a Quotation, confirm the SO with that product - Create a down payment for 50% of the SO - Confirm that invoice - Create another invoice for the SO for the rest of the SO and confirm it - Go to the project's profitability tab for the SO, you can see that we have the value of the SO + the amount of the down payment, leading to an incorrect sum, in the section Invoiced. Reason for the problem: When taking the invoices for the profitability of the project, since a down payment is another `sale.order.line`, we handle it in the method `_get_revenues_items_from_invoices`, and there we are taking into account the down payments. Fix: Elaborate the domain used to fetch the invoices in `_get_revenues_items_from_invoices_domain` to not take those that are down payments. Affected versions: - 16.0 - saas-16.1 - master opw-3195016 closes odoo/odoo#115050 X-original-commit: ae151ec16a0054420f5c2827a1924c87e5b672ba Signed-off-by: Xavier Bol (xbo) Signed-off-by: Piryns Victor (pivi) --- addons/sale_project/models/project.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/sale_project/models/project.py b/addons/sale_project/models/project.py index 52ab0f0f871..60aefaece64 100755 --- a/addons/sale_project/models/project.py +++ b/addons/sale_project/models/project.py @@ -410,7 +410,8 @@ class Project(models.Model): domain, [('move_id.move_type', 'in', self.env['account.move'].get_sale_types()), ('parent_state', 'in', ['draft', 'posted']), - ('price_subtotal', '>', 0)], + ('price_subtotal', '>', 0), + ('is_downpayment', '=', False)], ]) def _get_revenues_items_from_invoices(self, excluded_move_line_ids=None):