This commit is contained in:
2026-07-14 18:15:26 +02:00
parent bdf13f4fac
commit cf0c0923a6
3 changed files with 220 additions and 36 deletions

View File

@@ -6936,6 +6936,81 @@ description</t></is></c>
'linkage report must not alter the lot.qt ORM model'
self.assertFalse(hasattr(stock_module, 'LotQt'))
def test_linkage_report_final_validates_ordered_matching_fee(self):
'linkage final keeps budgeted estimate and validates matching ordered fee'
ShipmentIn = Pool().get('stock.shipment.in')
shipment = ShipmentIn()
shipment.bl_date = datetime.date(2026, 4, 30)
shipment.fees = []
shipment.moves = []
shipment.lotqt = []
currency = SimpleNamespace(code='USD')
unit = SimpleNamespace(symbol='MT')
product = SimpleNamespace(id=1, rec_name='Sulphuric Acid')
purchase = SimpleNamespace(
id=10,
number='P-10',
reference='26.0001',
currency=currency,
party=SimpleNamespace(id=20, rec_name='SUPPLIER SA'),
to_location=SimpleNamespace(rec_name='Odda'),
incoterm=SimpleNamespace(code='FOB'))
purchase_line = SimpleNamespace(
id=11,
product=product,
purchase=purchase,
quantity_theorical=Decimal('100'),
quantity=Decimal('100'),
unit_price=Decimal('80'),
unit=unit,
fees=[],
mtm=[])
fee_product = SimpleNamespace(id=30, name='Maritime freight')
supplier = SimpleNamespace(id=40, rec_name='FREIGHT CO')
budgeted_fee = SimpleNamespace(
id=201,
type='budgeted',
line=purchase_line,
sale_line=None,
product=fee_product,
supplier=supplier,
price=Decimal('100'),
quantity=Decimal('1'),
mode='lumpsum',
p_r='pay')
ordered_fee = SimpleNamespace(
id=202,
type='ordered',
line=purchase_line,
sale_line=None,
product=fee_product,
supplier=supplier,
price=Decimal('125'),
quantity=Decimal('1'),
mode='lumpsum',
p_r='pay')
purchase_line.fees = [budgeted_fee, ordered_fee]
lot = SimpleNamespace(
id=101,
lot_type='physic',
line=purchase_line,
sale_line=None)
shipment.incoming_moves = [SimpleNamespace(lot=lot)]
provisional_fee_row = [
row for row in shipment._get_report_linkage_summary_rows()
if row[0] == 'Costs' and row[1] == 'Maritime freight'][0]
self.assertEqual(provisional_fee_row[2], Decimal('-100'))
self.assertEqual(provisional_fee_row[3], Decimal('-100'))
shipment.report_linkage_status = 'FINAL'
final_fee_row = [
row for row in shipment._get_report_linkage_summary_rows()
if row[0] == 'Costs' and row[1] == 'Maritime freight'][0]
self.assertEqual(final_fee_row[2], Decimal('-100'))
self.assertEqual(final_fee_row[3], Decimal('-125'))
def test_lot_report_linkage_rejects_non_physical_lines(self):
'lot.report linkage report is only available for physical lines'
linkage_report = Pool().get('lot.report.linkage', type='report')