Add Packing list template
This commit is contained in:
@@ -764,6 +764,25 @@ class ShipmentIn(metaclass=PoolMeta):
|
||||
return self.bl_date.strftime('%d-%m-%Y')
|
||||
return ''
|
||||
|
||||
@property
|
||||
def report_packing_today_date(self):
|
||||
Date = Pool().get('ir.date')
|
||||
today = Date.today()
|
||||
if not today:
|
||||
return ''
|
||||
return f"{today.strftime('%B')} {today.day}, {today.year}"
|
||||
|
||||
@property
|
||||
def report_packing_weight_unit(self):
|
||||
line = self._get_report_trade_line()
|
||||
unit = getattr(line, 'unit', None) if line else None
|
||||
if unit:
|
||||
return (
|
||||
getattr(unit, 'symbol', None)
|
||||
or getattr(unit, 'rec_name', None)
|
||||
or '')
|
||||
return self.report_packing_invoice_qty_unit or 'KGS'
|
||||
|
||||
@property
|
||||
def report_packing_gross_weight(self):
|
||||
_, gross = self._get_report_weight_totals()
|
||||
|
||||
@@ -638,6 +638,34 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
self.assertEqual(
|
||||
shipment.report_insurance_surveyor, 'SGS')
|
||||
|
||||
def test_shipment_packing_helpers_use_today_and_trade_unit(self):
|
||||
'packing list helpers expose today date and trade line unit'
|
||||
ShipmentIn = Pool().get('stock.shipment.in')
|
||||
shipment = ShipmentIn()
|
||||
shipment.quantity = Decimal('1010')
|
||||
shipment.unit = Mock(symbol='KGS', rec_name='KGS')
|
||||
|
||||
trade_line = Mock()
|
||||
trade_line.unit = Mock(symbol='MT', rec_name='MT')
|
||||
lot = Mock(line=trade_line, sale_line=None)
|
||||
lot.get_current_quantity = Mock(return_value=Decimal('1010'))
|
||||
lot.get_current_gross_quantity = Mock(return_value=Decimal('1012'))
|
||||
move = Mock(lot=lot, quantity=Decimal('0'))
|
||||
shipment.incoming_moves = [move]
|
||||
shipment.moves = [move]
|
||||
|
||||
with patch(
|
||||
'trytond.modules.purchase_trade.stock.Pool'
|
||||
) as PoolMock:
|
||||
date_model = Mock()
|
||||
date_model.today.return_value = datetime.date(2026, 4, 8)
|
||||
PoolMock.return_value.get.return_value = date_model
|
||||
|
||||
self.assertEqual(
|
||||
shipment.report_packing_today_date, 'April 8, 2026')
|
||||
self.assertEqual(
|
||||
shipment.report_packing_weight_unit, 'MT')
|
||||
|
||||
def test_sale_report_multi_line_helpers_aggregate_all_lines(self):
|
||||
'sale report helpers aggregate quantity, price lines and shipment periods'
|
||||
Sale = Pool().get('sale.sale')
|
||||
|
||||
Reference in New Issue
Block a user