diff --git a/modules/account_invoice/invoice.py b/modules/account_invoice/invoice.py index 26652ca..8dd20a0 100755 --- a/modules/account_invoice/invoice.py +++ b/modules/account_invoice/invoice.py @@ -1288,14 +1288,16 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin, InvoiceReportMixin): remainder = sum(l.debit - l.credit for l in move_lines) if self.payment_term: payment_date = self.payment_term_date or self.invoice_date or today - model = str(self.lines[0].origin).split(",")[0] if self.lines[0].origin else None + origin = self.lines[0].origin if self.lines and self.lines[0].origin else None + model = str(origin).split(",")[0] if origin else None logger.info("MODEL:%s",model) + line = None if model: Line = Pool().get(model) - line = Line(int(str(self.lines[0].origin).split(",")[1])) + line = Line(int(str(origin).split(",")[1])) logger.info("LINE:%s",line) - term_lines = self.payment_term.compute( - self.total_amount, self.currency, payment_date, line) + term_lines = self.payment_term.compute( + self.total_amount, self.currency, payment_date, line) else: term_lines = [(self.payment_term_date or today, self.total_amount)] past_payment_term_dates = []