This commit is contained in:
2026-03-26 19:02:01 +01:00
parent 91acaba3dc
commit 841f7a1c20
2 changed files with 92 additions and 46 deletions

View File

@@ -2,7 +2,7 @@
<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:rpt="http://openoffice.org/2005/report" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:css3t="http://www.w3.org/TR/css3-text/" xmlns:officeooo="http://openoffice.org/2009/office" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
<office:meta>
<dc:title>Provisional Sale</dc:title>
<dc:title>Provisional Invoice</dc:title>
<meta:initial-creator>willen</meta:initial-creator>
<meta:creation-date>2018-12-09T16:20:00</meta:creation-date>
<dc:date>2026-03-26T18:22:40.515000000</dc:date>
@@ -3833,7 +3833,7 @@
<table:table-row table:style-name="Tableau3.1">
<table:table-cell table:style-name="Tableau3.A1" office:value-type="string">
<text:p text:style-name="P20"/>
<text:p text:style-name="P20">Provisional Sale</text:p>
<text:p text:style-name="P20">Provisional Invoice</text:p>
</table:table-cell>
<table:table-cell table:style-name="Tableau3.A1" office:value-type="string">
<text:p text:style-name="P20"/>
@@ -4072,4 +4072,4 @@
<text:p text:style-name="P36"/>
</office:text>
</office:body>
</office:document>
</office:document>

View File

@@ -6,19 +6,34 @@ from trytond.pool import PoolMeta
class Invoice(metaclass=PoolMeta):
__name__ = 'account.invoice'
def _get_report_purchase(self):
purchases = list(self.purchases or [])
return purchases[0] if purchases else None
def _get_report_sale(self):
# Bridge invoice templates to the originating sale so FODT files can
# reuse stable sale.report_* properties instead of complex expressions.
sales = list(self.sales or [])
return sales[0] if sales else None
def _get_report_trade(self):
return self._get_report_sale() or self._get_report_purchase()
def _get_report_purchase_line(self):
purchase = self._get_report_purchase()
if purchase and purchase.lines:
return purchase.lines[0]
def _get_report_sale_line(self):
sale = self._get_report_sale()
if sale and sale.lines:
return sale.lines[0]
def _get_report_trade_line(self):
return self._get_report_sale_line() or self._get_report_purchase_line()
def _get_report_lot(self):
line = self._get_report_sale_line()
line = self._get_report_trade_line()
if line and line.lots:
for lot in line.lots:
if lot.lot_type == 'physic':
@@ -37,81 +52,81 @@ class Invoice(metaclass=PoolMeta):
@property
def report_address(self):
sale = self._get_report_sale()
if sale and sale.report_address:
return sale.report_address
trade = self._get_report_trade()
if trade and trade.report_address:
return trade.report_address
if self.invoice_address and self.invoice_address.full_address:
return self.invoice_address.full_address
return ''
@property
def report_contract_number(self):
sale = self._get_report_sale()
if sale and sale.full_number:
return sale.full_number
trade = self._get_report_trade()
if trade and trade.full_number:
return trade.full_number
return self.origins or ''
@property
def report_shipment(self):
sale = self._get_report_sale()
if sale and sale.report_shipment:
return sale.report_shipment
trade = self._get_report_trade()
if trade and trade.report_shipment:
return trade.report_shipment
return self.description or ''
@property
def report_trader_initial(self):
sale = self._get_report_sale()
if sale and sale.trader:
return self.trader.initial
trade = self._get_report_trade()
if trade and getattr(trade, 'trader', None):
return trade.trader.initial or ''
return ''
@property
def report_operator_initial(self):
sale = self._get_report_sale()
if sale and sale.operator:
return self.operator.initial
trade = self._get_report_trade()
if trade and getattr(trade, 'operator', None):
return trade.operator.initial or ''
return ''
@property
def report_product_description(self):
line = self._get_report_sale_line()
line = self._get_report_trade_line()
if line and line.product:
return line.product.description or ''
return ''
@property
def report_crop_name(self):
sale = self._get_report_sale()
if sale and sale.crop:
return sale.crop.name or ''
trade = self._get_report_trade()
if trade and getattr(trade, 'crop', None):
return trade.crop.name or ''
return ''
@property
def report_attributes_name(self):
line = self._get_report_sale_line()
line = self._get_report_trade_line()
if line:
return line.attributes_name or ''
return getattr(line, 'attributes_name', '') or ''
return ''
@property
def report_price(self):
sale = self._get_report_sale()
if sale and sale.report_price:
return sale.report_price
trade = self._get_report_trade()
if trade and trade.report_price:
return trade.report_price
return ''
@property
def report_payment_date(self):
sale = self._get_report_sale()
if sale and sale.report_payment_date:
return sale.report_payment_date
trade = self._get_report_trade()
if trade and trade.report_payment_date:
return trade.report_payment_date
return ''
@property
def report_payment_description(self):
sale = self._get_report_sale()
if sale and sale.payment_term:
return sale.payment_term.description or ''
trade = self._get_report_trade()
if trade and trade.payment_term:
return trade.payment_term.description or ''
if self.payment_term:
return self.payment_term.description or ''
return ''
@@ -121,6 +136,12 @@ class Invoice(metaclass=PoolMeta):
sale = self._get_report_sale()
if sale and sale.report_nb_bale:
return sale.report_nb_bale
line = self._get_report_trade_line()
if line and line.lots:
nb_bale = sum(
lot.lot_qt for lot in line.lots if lot.lot_type == 'physic'
)
return 'NB BALES: ' + str(int(nb_bale))
return ''
@property
@@ -128,13 +149,25 @@ class Invoice(metaclass=PoolMeta):
sale = self._get_report_sale()
if sale and sale.report_gross != '':
return sale.report_gross
line = self._get_report_trade_line()
if line and line.lots:
return sum(
lot.get_current_gross_quantity_converted()
for lot in line.lots if lot.lot_type == 'physic'
)
return ''
@property
def report_net(self):
sale = self._get_report_sale()
if sale and sale.report_net != '':
return sale.report_net
trade = self._get_report_trade()
if trade and getattr(trade, 'report_net', '') != '':
return trade.report_net
line = self._get_report_trade_line()
if line and line.lots:
return sum(
lot.get_current_quantity_converted()
for lot in line.lots if lot.lot_type == 'physic'
)
if self.lines:
return self.lines[0].quantity
return ''
@@ -168,11 +201,14 @@ class Invoice(metaclass=PoolMeta):
@property
def report_incoterm(self):
sale = self._get_report_sale()
if not sale:
trade = self._get_report_trade()
if not trade:
return ''
incoterm = sale.incoterm.code if sale.incoterm else ''
location = sale.incoterm_location.party_name if sale.incoterm_location else ''
incoterm = trade.incoterm.code if getattr(trade, 'incoterm', None) else ''
location = (
trade.incoterm_location.party_name
if getattr(trade, 'incoterm_location', None) else ''
)
if incoterm and location:
return f"{incoterm} {location}"
return incoterm or location
@@ -180,15 +216,25 @@ class Invoice(metaclass=PoolMeta):
@property
def report_proforma_invoice_number(self):
lot = self._get_report_lot()
if lot and lot.sale_invoice_line_prov and lot.sale_invoice_line_prov.invoice:
return lot.sale_invoice_line_prov.invoice.number or ''
if lot:
line = (
getattr(lot, 'sale_invoice_line_prov', None)
or getattr(lot, 'invoice_line_prov', None)
)
if line and line.invoice:
return line.invoice.number or ''
return ''
@property
def report_proforma_invoice_date(self):
lot = self._get_report_lot()
if lot and lot.sale_invoice_line_prov and lot.sale_invoice_line_prov.invoice:
return lot.sale_invoice_line_prov.invoice.invoice_date
if lot:
line = (
getattr(lot, 'sale_invoice_line_prov', None)
or getattr(lot, 'invoice_line_prov', None)
)
if line and line.invoice:
return line.invoice.invoice_date
@property
def report_controller_name(self):