From 1c201bb8ae58be09923cf5086c71d32263004c1c Mon Sep 17 00:00:00 2001 From: "Abdelouahab (abla)" Date: Wed, 9 Nov 2022 13:13:43 +0000 Subject: [PATCH] [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 --- addons/sale/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale/models/sale_order.py b/addons/sale/models/sale_order.py index 34d635dff16..aa39593183f 100644 --- a/addons/sale/models/sale_order.py +++ b/addons/sale/models/sale_order.py @@ -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,