This commit is contained in:
2026-04-02 12:12:49 +02:00
parent 2958e1fb9e
commit 51ced23ab8
7 changed files with 158 additions and 21 deletions

View File

@@ -1,6 +1,7 @@
from decimal import Decimal
from trytond.pool import Pool, PoolMeta
from trytond.modules.purchase_trade.numbers_to_words import amount_to_currency_words
class Invoice(metaclass=PoolMeta):
@@ -298,6 +299,10 @@ class Invoice(metaclass=PoolMeta):
sale = self._get_report_sale()
if sale and sale.report_gross != '':
return sale.report_gross
if self.lines:
return sum(
Decimal(str(getattr(line, 'quantity', 0) or 0))
for line in self._get_report_invoice_lines())
line = self._get_report_trade_line()
if line and line.lots:
return sum(
@@ -311,6 +316,10 @@ class Invoice(metaclass=PoolMeta):
trade = self._get_report_trade()
if trade and getattr(trade, 'report_net', '') != '':
return trade.report_net
if self.lines:
return sum(
Decimal(str(getattr(line, 'quantity', 0) or 0))
for line in self._get_report_invoice_lines())
line = self._get_report_trade_line()
if line and line.lots:
return sum(
@@ -463,6 +472,11 @@ class InvoiceLine(metaclass=PoolMeta):
@property
def report_rate_value(self):
origin = self._get_report_trade_line()
if origin and getattr(origin, 'price_type', None) == 'basis':
if getattr(origin, 'enable_linked_currency', False) and getattr(origin, 'linked_currency', None):
return Decimal(str(origin.premium or 0))
return Decimal(str(origin._get_premium_price() or 0))
return self.unit_price if self.unit_price is not None else ''
@property
@@ -475,6 +489,12 @@ class InvoiceLine(metaclass=PoolMeta):
@property
def report_rate_price_words(self):
origin = self._get_report_trade_line()
if origin and getattr(origin, 'price_type', None) == 'basis':
value = self.report_rate_value
if self.report_rate_currency_upper == 'USC':
return amount_to_currency_words(value, 'USC', 'USC')
return amount_to_currency_words(value)
trade = self._get_report_trade()
if trade and getattr(trade, 'report_price', None):
return trade.report_price