Add Bill template
This commit is contained in:
@@ -598,7 +598,7 @@ class Sale(metaclass=PoolMeta):
|
|||||||
return '\n'.join(periods)
|
return '\n'.join(periods)
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def report_payment_date(self):
|
def report_payment_date(self):
|
||||||
line = self._get_report_first_line()
|
line = self._get_report_first_line()
|
||||||
if line:
|
if line:
|
||||||
@@ -609,6 +609,51 @@ class Sale(metaclass=PoolMeta):
|
|||||||
if payment_date:
|
if payment_date:
|
||||||
payment_date = format_date_en(payment_date)
|
payment_date = format_date_en(payment_date)
|
||||||
return 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
|
@property
|
||||||
def report_shipment(self):
|
def report_shipment(self):
|
||||||
|
|||||||
@@ -466,7 +466,7 @@
|
|||||||
<table:table-cell table:style-name="Tableau1.A1" table:number-columns-spanned="2" office:value-type="string">
|
<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"><format_date(sale.sale_date, sale.party.lang)></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"><format_date(sale.sale_date, sale.party.lang)></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="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"><sale.payment_term.rec_name if sale.payment_term else ''></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"><format_date(sale.report_bill_maturity_date, sale.party.lang) if sale.report_bill_maturity_date else ''></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"/>
|
<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:table-cell>
|
||||||
<table:covered-table-cell/>
|
<table:covered-table-cell/>
|
||||||
<table:table-cell table:style-name="Tableau1.A1" office:value-type="string">
|
<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"><format_currency(sale.lines[0].unit_price, sale.party.lang, sale.currency) if sale.lines else ''></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"><format_currency(sale.report_bill_amount, sale.party.lang, sale.currency)></text:placeholder></text:span><text:span text:style-name="T3"/></text:p>
|
||||||
</table:table-cell>
|
</table:table-cell>
|
||||||
</table:table-row>
|
</table:table-row>
|
||||||
<table:table-row table:style-name="Tableau1.2">
|
<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">
|
<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"><sale.reference if sale.reference else ''></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"><sale.report_bill_amount_words></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"/>
|
||||||
</table:table-cell>
|
</table:table-cell>
|
||||||
<table:covered-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">
|
<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"><sale.currency.symbol if sale.currency else ''></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"><sale.currency.symbol if sale.currency else ''></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="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"><sale.party.addresses[0].country.name if sale.party and sale.party.addresses else ''></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"><(sale.party.addresses[0].country.name.upper()) if sale.party and sale.party.addresses and sale.party.addresses[0].country else ''></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"/>
|
<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"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user