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):

View File

@@ -466,7 +466,7 @@
<table:table-cell table:style-name="Tableau1.A1" table:number-columns-spanned="2" office:value-type="string">
<text:p text:style-name="P7" loext:marker-style-name="T1"><text:span text:style-name="T1"><text:placeholder text:placeholder-type="text">&lt;format_date(sale.sale_date, sale.party.lang)&gt;</text:placeholder></text:span><text:span text:style-name="T1"/></text:p>
<text:p text:style-name="P8" loext:marker-style-name="T4"/>
<text:p text:style-name="P7" loext:marker-style-name="T1"><text:span text:style-name="T1"><text:placeholder text:placeholder-type="text">&lt;sale.payment_term.rec_name if sale.payment_term else &apos;&apos;&gt;</text:placeholder></text:span><text:span text:style-name="T1"/></text:p>
<text:p text:style-name="P7" loext:marker-style-name="T1"><text:span text:style-name="T1"><text:placeholder text:placeholder-type="text">&lt;format_date(sale.report_bill_maturity_date, sale.party.lang) if sale.report_bill_maturity_date else &apos;&apos;&gt;</text:placeholder></text:span><text:span text:style-name="T1"/></text:p>
<text:p text:style-name="P6" loext:marker-style-name="T1"/>
<text:p text:style-name="P6" loext:marker-style-name="T1"/>
<text:p text:style-name="P6" loext:marker-style-name="T1"/>
@@ -477,12 +477,12 @@
</table:table-cell>
<table:covered-table-cell/>
<table:table-cell table:style-name="Tableau1.A1" office:value-type="string">
<text:p text:style-name="P7" loext:marker-style-name="T5"><text:span text:style-name="T3"><text:placeholder text:placeholder-type="text">&lt;format_currency(sale.lines[0].unit_price, sale.party.lang, sale.currency) if sale.lines else &apos;&apos;&gt;</text:placeholder></text:span><text:span text:style-name="T3"/></text:p>
<text:p text:style-name="P7" loext:marker-style-name="T5"><text:span text:style-name="T3"><text:placeholder text:placeholder-type="text">&lt;format_currency(sale.report_bill_amount, sale.party.lang, sale.currency)&gt;</text:placeholder></text:span><text:span text:style-name="T3"/></text:p>
</table:table-cell>
</table:table-row>
<table:table-row table:style-name="Tableau1.2">
<table:table-cell table:style-name="Tableau1.A1" table:number-columns-spanned="6" office:value-type="string">
<text:p text:style-name="P1" loext:marker-style-name="T1"><text:span text:style-name="T1"><text:placeholder text:placeholder-type="text">&lt;sale.reference if sale.reference else &apos;&apos;&gt;</text:placeholder></text:span><text:span text:style-name="T1"/></text:p>
<text:p text:style-name="P1" loext:marker-style-name="T1"><text:span text:style-name="T1">***<text:placeholder text:placeholder-type="text">&lt;sale.report_bill_amount_words&gt;</text:placeholder>***</text:span><text:span text:style-name="T1"/></text:p>
<text:p text:style-name="P2" loext:marker-style-name="T1"/>
</table:table-cell>
<table:covered-table-cell/>
@@ -501,7 +501,7 @@
<table:table-cell table:style-name="Tableau1.A1" table:number-columns-spanned="4" office:value-type="string">
<text:p text:style-name="P1" loext:marker-style-name="T1"><text:span text:style-name="T1"><text:placeholder text:placeholder-type="text">&lt;sale.currency.symbol if sale.currency else &apos;&apos;&gt;</text:placeholder></text:span><text:span text:style-name="T1"/></text:p>
<text:p text:style-name="P3" loext:marker-style-name="T6"/>
<text:p text:style-name="P1" loext:marker-style-name="T1"><text:span text:style-name="T1"><text:s text:c="13"/><text:placeholder text:placeholder-type="text">&lt;sale.party.addresses[0].country.name if sale.party and sale.party.addresses else &apos;&apos;&gt;</text:placeholder></text:span><text:span text:style-name="T1"/></text:p>
<text:p text:style-name="P1" loext:marker-style-name="T1"><text:span text:style-name="T1"><text:s text:c="13"/><text:placeholder text:placeholder-type="text">&lt;(sale.party.addresses[0].country.name.upper()) if sale.party and sale.party.addresses and sale.party.addresses[0].country else &apos;&apos;&gt;</text:placeholder></text:span><text:span text:style-name="T1"/></text:p>
<text:p text:style-name="P2" loext:marker-style-name="T1"/>
<text:p text:style-name="P2" loext:marker-style-name="T1"/>
<text:p text:style-name="P2" loext:marker-style-name="T1"/>