[FIX] account: render draft invoice without early payment

Current behaviour:

500: Internal Server Error
Error while rendering the template account.report_invoice_document

Steps to reproduce:

Accounting > Configuration > invoicing > Payment Terms
New > Create and save a payment term with 2 lines
    For example :
        - name 80/20 test
        - line_1 : 80% after 0 days
        - line_2 : 20% after 30 days

Sales > Orders > Quotations
Chose any > use payment terms 80/20 test
Save and create associated invoice > chose regular invoice
> create draft invoice > preview > 500: Internal Server Error

Cause of the issue:

The method _get_amount_due_after_discount() called during the rendering
of the template does not return a value in case self.early_discount is
False.

Fix:

Return total_amount by default since no discount is applied.

opw-3683708

closes odoo/odoo#155080

X-original-commit: c8154b6aa57cc42e352260c7f75e52cd29a2d52d
Signed-off-by: Quentin De Paoli <qdp@odoo.com>
Signed-off-by: Lancelot Semal (lase) <lase@odoo.com>
This commit is contained in:
lase@odoo.com
2024-02-23 08:42:51 +00:00
parent c8d053f271
commit bb77d9e554
@@ -60,6 +60,7 @@ class AccountPaymentTerm(models.Model):
else:
discount_amount_currency = self.currency_id.round(total_amount - (total_amount * (1 - (percentage))))
return total_amount - discount_amount_currency
return total_amount
@api.depends('company_id')
def _compute_discount_computation(self):