Add Packing list template

This commit is contained in:
2026-04-08 10:08:17 +02:00
parent 4d94aa78ed
commit add4cdc137
3 changed files with 50 additions and 3 deletions

View File

@@ -764,6 +764,25 @@ class ShipmentIn(metaclass=PoolMeta):
return self.bl_date.strftime('%d-%m-%Y') return self.bl_date.strftime('%d-%m-%Y')
return '' 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 @property
def report_packing_gross_weight(self): def report_packing_gross_weight(self):
_, gross = self._get_report_weight_totals() _, gross = self._get_report_weight_totals()

View File

@@ -638,6 +638,34 @@ class PurchaseTradeTestCase(ModuleTestCase):
self.assertEqual( self.assertEqual(
shipment.report_insurance_surveyor, 'SGS') 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): def test_sale_report_multi_line_helpers_aggregate_all_lines(self):
'sale report helpers aggregate quantity, price lines and shipment periods' 'sale report helpers aggregate quantity, price lines and shipment periods'
Sale = Pool().get('sale.sale') Sale = Pool().get('sale.sale')

View File

@@ -1662,7 +1662,7 @@
<text:p text:style-name="P13" loext:marker-style-name="T7"/> <text:p text:style-name="P13" loext:marker-style-name="T7"/>
<text:p text:style-name="P13" loext:marker-style-name="T7"/> <text:p text:style-name="P13" loext:marker-style-name="T7"/>
<text:p text:style-name="P13" loext:marker-style-name="T7"/> <text:p text:style-name="P13" loext:marker-style-name="T7"/>
<text:p text:style-name="P19" loext:marker-style-name="T9"><text:span text:style-name="T8"><text:time style:data-style-name="N10041" text:time-value="2026-04-08T09:32:08.310000034">April 8, 2026</text:time></text:span></text:p> <text:p text:style-name="P19" loext:marker-style-name="T9"><text:span text:style-name="T8"><text:placeholder text:placeholder-type="text">&lt;records[0].report_packing_today_date or &apos;&apos;&gt;</text:placeholder></text:span></text:p>
<text:p text:style-name="P14" loext:marker-style-name="T9"/> <text:p text:style-name="P14" loext:marker-style-name="T9"/>
<text:p text:style-name="P14" loext:marker-style-name="T9"/> <text:p text:style-name="P14" loext:marker-style-name="T9"/>
<text:p text:style-name="P16" loext:marker-style-name="T10"/> <text:p text:style-name="P16" loext:marker-style-name="T10"/>
@@ -1684,9 +1684,9 @@
<text:p text:style-name="P15" loext:marker-style-name="T9"/> <text:p text:style-name="P15" loext:marker-style-name="T9"/>
<text:p text:style-name="P18" loext:marker-style-name="T17"/> <text:p text:style-name="P18" loext:marker-style-name="T17"/>
<text:p text:style-name="P18" loext:marker-style-name="T17"/> <text:p text:style-name="P18" loext:marker-style-name="T17"/>
<text:p text:style-name="P20" loext:marker-style-name="T17"><text:span text:style-name="T17">Gross weight<text:tab/><text:tab/>:<text:tab/><text:placeholder text:placeholder-type="text">&lt;records[0].report_packing_gross_weight or &apos;&apos;&gt;</text:placeholder><text:tab/>KGS</text:span><text:span text:style-name="T17"/></text:p> <text:p text:style-name="P20" loext:marker-style-name="T17"><text:span text:style-name="T17">Gross weight<text:tab/><text:tab/>:<text:tab/><text:placeholder text:placeholder-type="text">&lt;records[0].report_packing_gross_weight or &apos;&apos;&gt;</text:placeholder><text:tab/><text:placeholder text:placeholder-type="text">&lt;records[0].report_packing_weight_unit or &apos;&apos;&gt;</text:placeholder></text:span><text:span text:style-name="T17"/></text:p>
<text:p text:style-name="P18" loext:marker-style-name="T17"/> <text:p text:style-name="P18" loext:marker-style-name="T17"/>
<text:p text:style-name="P20" loext:marker-style-name="T18"><text:span text:style-name="T18">Net weight<text:tab/><text:tab/>:<text:tab/><text:placeholder text:placeholder-type="text">&lt;records[0].report_packing_net_weight or &apos;&apos;&gt;</text:placeholder><text:tab/><text:tab/>KGS</text:span><text:span text:style-name="T18"/></text:p> <text:p text:style-name="P20" loext:marker-style-name="T18"><text:span text:style-name="T18">Net weight<text:tab/><text:tab/>:<text:tab/><text:placeholder text:placeholder-type="text">&lt;records[0].report_packing_net_weight or &apos;&apos;&gt;</text:placeholder><text:tab/><text:placeholder text:placeholder-type="text">&lt;records[0].report_packing_weight_unit or &apos;&apos;&gt;</text:placeholder></text:span><text:span text:style-name="T18"/></text:p>
<text:p text:style-name="P17" loext:marker-style-name="T11"/> <text:p text:style-name="P17" loext:marker-style-name="T11"/>
<text:p text:style-name="P17" loext:marker-style-name="T11"/> <text:p text:style-name="P17" loext:marker-style-name="T11"/>
<text:p text:style-name="P17" loext:marker-style-name="T11"/> <text:p text:style-name="P17" loext:marker-style-name="T11"/>