main #7

Merged
admin merged 620 commits from main into dev 2026-03-29 13:03:25 +00:00
2 changed files with 92 additions and 46 deletions
Showing only changes of commit 841f7a1c20 - Show all commits

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: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> <office:meta>
<dc:title>Provisional Sale</dc:title> <dc:title>Provisional Invoice</dc:title>
<meta:initial-creator>willen</meta:initial-creator> <meta:initial-creator>willen</meta:initial-creator>
<meta:creation-date>2018-12-09T16:20:00</meta:creation-date> <meta:creation-date>2018-12-09T16:20:00</meta:creation-date>
<dc:date>2026-03-26T18:22:40.515000000</dc: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-row table:style-name="Tableau3.1">
<table:table-cell table:style-name="Tableau3.A1" office:value-type="string"> <table:table-cell table:style-name="Tableau3.A1" office:value-type="string">
<text:p text:style-name="P20"/> <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:table-cell table:style-name="Tableau3.A1" office:value-type="string"> <table:table-cell table:style-name="Tableau3.A1" office:value-type="string">
<text:p text:style-name="P20"/> <text:p text:style-name="P20"/>
@@ -4072,4 +4072,4 @@
<text:p text:style-name="P36"/> <text:p text:style-name="P36"/>
</office:text> </office:text>
</office:body> </office:body>
</office:document> </office:document>

View File

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