[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) <xbo@odoo.com>
Signed-off-by: Piryns Victor (pivi) <pivi@odoo.com>
This commit is contained in:
Victor Piryns (pivi)
2023-03-13 13:13:53 +01:00
parent 0658de98a9
commit eb73917c0f
+2 -1
View File
@@ -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):