[FIX] sale: do not take into account old invoices in sub renew

To Reproduce
============
- create a subscription
- confirm it and create invoice for it then confirm it too
- go back to the subscription and renew it
- from *Action* generate a payment link
- a validation error will be raised

Problem
=======
we can't generate the payment link because the amount is 0, this value came from the fact that we substract
the sum of invoices amount linked to this subscription from the total amount.

Solution
========
The invoices from the old subscription are kept just as history in the new one, and must not be taken into account when
computing the amount, so a condition was added to remove theses kind of invoices from computation of amount.

opw-3052816

closes odoo/odoo#106104

X-original-commit: 62e6db19d6ec17805756f277ca6f17c50281f707
Signed-off-by: abla001 <abla@odoo.com>
This commit is contained in:
Abdelouahab (abla)
2022-11-21 11:50:18 +01:00
parent b1f87e1088
commit 1c201bb8ae
+1 -1
View File
@@ -1319,7 +1319,7 @@ class SaleOrder(models.Model):
self.ensure_one()
return {
'description': self.name,
'amount': self.amount_total - sum(self.invoice_ids.filtered(lambda x: x.state != 'cancel').mapped('amount_total')),
'amount': self.amount_total - sum(self.invoice_ids.filtered(lambda x: x.state != 'cancel' and x.invoice_line_ids.sale_line_ids.order_id == self).mapped('amount_total')),
'currency_id': self.currency_id.id,
'partner_id': self.partner_id.id,
'amount_max': self.amount_total,