This commit is contained in:
2026-03-27 07:30:15 +01:00
parent 0979021f41
commit 22d186f0ac
4 changed files with 210 additions and 98 deletions

View File

@@ -6,6 +6,12 @@ from trytond.pool import PoolMeta
class Invoice(metaclass=PoolMeta):
__name__ = 'account.invoice'
def _get_report_invoice_line(self):
for line in self.lines or []:
if getattr(line, 'type', None) == 'line':
return line
return self.lines[0] if self.lines else None
def _get_report_purchase(self):
purchases = list(self.purchases or [])
return purchases[0] if purchases else None
@@ -128,6 +134,41 @@ class Invoice(metaclass=PoolMeta):
return trade.report_price
return ''
@property
def report_rate_currency_upper(self):
line = self._get_report_invoice_line()
if line:
return line.report_rate_currency_upper
return ''
@property
def report_rate_value(self):
line = self._get_report_invoice_line()
if line:
return line.report_rate_value
return ''
@property
def report_rate_unit_upper(self):
line = self._get_report_invoice_line()
if line:
return line.report_rate_unit_upper
return ''
@property
def report_rate_price_words(self):
line = self._get_report_invoice_line()
if line:
return line.report_rate_price_words
return self.report_price or ''
@property
def report_rate_pricing_text(self):
line = self._get_report_invoice_line()
if line:
return line.report_rate_pricing_text
return ''
@property
def report_payment_date(self):
trade = self._get_report_trade()
@@ -165,7 +206,7 @@ class Invoice(metaclass=PoolMeta):
line = self._get_report_trade_line()
if line and line.lots:
return sum(
lot.get_current_gross_quantity_converted()
lot.get_current_gross_quantity()
for lot in line.lots if lot.lot_type == 'physic'
)
return ''
@@ -178,7 +219,7 @@ class Invoice(metaclass=PoolMeta):
line = self._get_report_trade_line()
if line and line.lots:
return sum(
lot.get_current_quantity_converted()
lot.get_current_quantity()
for lot in line.lots if lot.lot_type == 'physic'
)
if self.lines:
@@ -190,7 +231,7 @@ class Invoice(metaclass=PoolMeta):
net = self.report_net
if net == '':
return ''
return Decimal(net) * Decimal('2.20462')
return round(Decimal(net) * Decimal('2204.62'),2)
@property
def report_bl_date(self):
@@ -285,6 +326,9 @@ class InvoiceLine(metaclass=PoolMeta):
return None
return getattr(origin, 'sale', None) or getattr(origin, 'purchase', None)
def _get_report_trade_line(self):
return getattr(self, 'origin', None)
@property
def report_product_description(self):
if self.product:
@@ -298,6 +342,38 @@ class InvoiceLine(metaclass=PoolMeta):
def report_description_upper(self):
return (self.description or '').upper()
@property
def report_rate_currency_upper(self):
origin = self._get_report_trade_line()
currency = getattr(origin, 'linked_currency', None) or self.currency
if currency and currency.rec_name:
return currency.rec_name.upper()
return ''
@property
def report_rate_value(self):
return self.unit_price if self.unit_price is not None else ''
@property
def report_rate_unit_upper(self):
origin = self._get_report_trade_line()
unit = getattr(origin, 'linked_unit', None) or self.unit
if unit and unit.rec_name:
return unit.rec_name.upper()
return ''
@property
def report_rate_price_words(self):
trade = self._get_report_trade()
if trade and getattr(trade, 'report_price', None):
return trade.report_price
return ''
@property
def report_rate_pricing_text(self):
origin = self._get_report_trade_line()
return getattr(origin, 'get_pricing_text', '') or ''
@property
def report_crop_name(self):
trade = self._get_report_trade()