02.04.26
This commit is contained in:
@@ -377,31 +377,15 @@ class Invoice(metaclass=PoolMeta):
|
||||
def report_nb_bale(self):
|
||||
lots = self._get_report_invoice_lots()
|
||||
if lots:
|
||||
Uom = Pool().get('product.uom')
|
||||
line = self._get_report_invoice_line() or self._get_report_trade_line()
|
||||
invoice_unit = getattr(line, 'unit', None) if line else None
|
||||
net = Decimal(str(self.report_net or 0))
|
||||
total_packages = Decimal(0)
|
||||
total_weight = Decimal(0)
|
||||
package_unit = None
|
||||
for lot in lots:
|
||||
if getattr(lot, 'lot_qt', None):
|
||||
total_packages += Decimal(str(lot.lot_qt or 0))
|
||||
if not package_unit and getattr(lot, 'lot_unit', None):
|
||||
package_unit = lot.lot_unit
|
||||
lot_quantity = Decimal(str(getattr(lot, 'lot_quantity', 0) or 0))
|
||||
lot_unit_line = getattr(lot, 'lot_unit_line', None)
|
||||
if lot_quantity and lot_unit_line and invoice_unit:
|
||||
total_weight += Decimal(str(
|
||||
Uom.compute_qty(
|
||||
lot_unit_line, float(lot_quantity), invoice_unit,
|
||||
round=False) or 0))
|
||||
if total_packages:
|
||||
package_qty = total_packages
|
||||
if total_weight and net:
|
||||
package_qty = (
|
||||
net / (total_weight / total_packages))
|
||||
package_qty = package_qty.quantize(
|
||||
package_qty = total_packages.quantize(
|
||||
Decimal('1'), rounding=ROUND_HALF_UP)
|
||||
if package_qty:
|
||||
label = self._format_report_package_label(package_unit)
|
||||
|
||||
Reference in New Issue
Block a user