Add Bill template

This commit is contained in:
2026-04-08 11:24:23 +02:00
parent 63d8266a9c
commit e9ff9c76ab
2 changed files with 50 additions and 5 deletions

View File

@@ -598,7 +598,7 @@ class Sale(metaclass=PoolMeta):
return '\n'.join(periods)
return ''
@property
@property
def report_payment_date(self):
line = self._get_report_first_line()
if line:
@@ -609,6 +609,51 @@ class Sale(metaclass=PoolMeta):
if payment_date:
payment_date = format_date_en(payment_date)
return payment_date
def _get_report_bill_amount(self):
invoices = [
invoice for invoice in (self.invoices or [])
if getattr(invoice, 'state', None) != 'cancelled'
]
if invoices:
invoice = sorted(
invoices,
key=lambda i: (
getattr(i, 'invoice_date', None) or datetime.date.min,
getattr(i, 'id', 0)))[0]
return Decimal(str(getattr(invoice, 'total_amount', 0) or 0))
return Decimal(str(self.total_amount or 0))
@property
def report_bill_amount(self):
return self._get_report_bill_amount()
@property
def report_bill_amount_words(self):
value = self._get_report_bill_amount()
if self.currency and (self.currency.rec_name or '').upper() == 'USC':
return amount_to_currency_words(value, 'USC', 'USC')
return amount_to_currency_words(value)
@property
def report_bill_maturity_date(self):
maturity_dates = []
for invoice in (self.invoices or []):
if getattr(invoice, 'state', None) == 'cancelled':
continue
for line in (invoice.lines_to_pay or []):
if getattr(line, 'maturity_date', None):
maturity_dates.append(line.maturity_date)
if maturity_dates:
return min(maturity_dates)
if self.lc_date:
return self.lc_date
line = self._get_report_first_line()
if line and self.payment_term and self.payment_term.lines:
Date = Pool().get('ir.date')
return self.payment_term.lines[0].get_date(Date.today(), line)
@property
def report_shipment(self):