02.04.26
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from decimal import Decimal
|
||||
from decimal import Decimal, ROUND_HALF_UP
|
||||
|
||||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.modules.purchase_trade.numbers_to_words import amount_to_currency_words
|
||||
@@ -329,12 +329,26 @@ class Invoice(metaclass=PoolMeta):
|
||||
|
||||
@property
|
||||
def report_nb_bale(self):
|
||||
unit = self.report_weight_unit_upper
|
||||
net = self.report_net
|
||||
if net != '' and unit == 'MT':
|
||||
quantity = abs(Decimal(str(net or 0))).quantize(Decimal('1'))
|
||||
if quantity:
|
||||
return 'NB BALES: ' + str(int(quantity))
|
||||
line = self._get_report_trade_line() or self._get_report_invoice_line()
|
||||
unit = getattr(line, 'unit', None) if line else None
|
||||
if net != '' and unit:
|
||||
Uom = Pool().get('product.uom')
|
||||
bale_uom = Uom.get_by_name('bale')
|
||||
if not bale_uom:
|
||||
bale_uoms = Uom.search([
|
||||
('name', 'ilike', 'bale'),
|
||||
], limit=1)
|
||||
bale_uom = bale_uoms[0] if bale_uoms else None
|
||||
if bale_uom and getattr(unit, 'category', None) == getattr(
|
||||
bale_uom, 'category', None):
|
||||
bale_qty = Decimal(str(
|
||||
Uom.compute_qty(unit, float(net), bale_uom, round=False)
|
||||
or 0))
|
||||
bale_qty = bale_qty.quantize(
|
||||
Decimal('1'), rounding=ROUND_HALF_UP)
|
||||
if bale_qty:
|
||||
return 'NB BALES: ' + str(int(bale_qty))
|
||||
sale = self._get_report_sale()
|
||||
if sale and sale.report_nb_bale:
|
||||
return sale.report_nb_bale
|
||||
|
||||
Reference in New Issue
Block a user