Improve linkage report layout
This commit is contained in:
@@ -1714,6 +1714,15 @@ class ShipmentIn(metaclass=PoolMeta):
|
||||
amount = Decimal(str(amount or 0))
|
||||
return -amount if getattr(fee, 'p_r', None) == 'pay' else amount
|
||||
|
||||
@classmethod
|
||||
def _report_linkage_fee_label(cls, fee):
|
||||
product = getattr(fee, 'product', None)
|
||||
label = (
|
||||
getattr(product, 'name', None)
|
||||
or cls._report_rec_name(product)
|
||||
or 'Fee')
|
||||
return label
|
||||
|
||||
def _get_report_linkage_summary_rows(self):
|
||||
purchase_lines = self._get_report_linkage_purchase_lines()
|
||||
sale_lines = self._get_report_linkage_sale_lines()
|
||||
@@ -1728,11 +1737,13 @@ class ShipmentIn(metaclass=PoolMeta):
|
||||
rows.append(('Sales', '', sale_total, sale_total))
|
||||
|
||||
fee_total = Decimal('0')
|
||||
fee_rows = {}
|
||||
for fee in self._get_report_linkage_fees():
|
||||
product = getattr(fee, 'product', None)
|
||||
label = self._report_rec_name(product) or 'Fee'
|
||||
label = self._report_linkage_fee_label(fee)
|
||||
amount = self._report_fee_amount(fee)
|
||||
fee_total += amount
|
||||
fee_rows[label] = fee_rows.get(label, Decimal('0')) + amount
|
||||
for label, amount in fee_rows.items():
|
||||
rows.append(('Costs', label, amount, amount))
|
||||
|
||||
if rows:
|
||||
@@ -2940,6 +2951,10 @@ class LotQt(metaclass=PoolMeta):
|
||||
def _report_fee_amount(cls, fee):
|
||||
return ShipmentIn._report_fee_amount(fee)
|
||||
|
||||
@classmethod
|
||||
def _report_linkage_fee_label(cls, fee):
|
||||
return ShipmentIn._report_linkage_fee_label(fee)
|
||||
|
||||
@classmethod
|
||||
def _report_column(cls, rows, index, amount=False):
|
||||
return ShipmentIn._report_column(rows, index, amount=amount)
|
||||
@@ -4710,6 +4725,10 @@ class LotReportLinkageRecord:
|
||||
def _report_fee_amount(cls, fee):
|
||||
return ShipmentIn._report_fee_amount(fee)
|
||||
|
||||
@classmethod
|
||||
def _report_linkage_fee_label(cls, fee):
|
||||
return ShipmentIn._report_linkage_fee_label(fee)
|
||||
|
||||
@classmethod
|
||||
def _report_column(cls, rows, index, amount=False):
|
||||
return ShipmentIn._report_column(rows, index, amount=amount)
|
||||
|
||||
@@ -6562,7 +6562,17 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
ShipmentIn = Pool().get('stock.shipment.in')
|
||||
shipment = ShipmentIn()
|
||||
shipment.bl_date = datetime.date(2026, 4, 30)
|
||||
shipment.fees = []
|
||||
freight_product = SimpleNamespace(
|
||||
rec_name='[Maritime Freight] Maritime freight',
|
||||
name='Maritime freight')
|
||||
shipment.fees = [
|
||||
SimpleNamespace(
|
||||
id=201, product=freight_product, price=Decimal('10'),
|
||||
quantity=Decimal('1'), mode='lumpsum', p_r='pay'),
|
||||
SimpleNamespace(
|
||||
id=202, product=freight_product, price=Decimal('15'),
|
||||
quantity=Decimal('1'), mode='lumpsum', p_r='pay'),
|
||||
]
|
||||
shipment.moves = []
|
||||
shipment.lotqt = []
|
||||
|
||||
@@ -6637,6 +6647,12 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
self.assertIn('Sales', shipment.report_linkage_summary_groups)
|
||||
self.assertIn('-8,000.000', shipment.report_linkage_summary_estimated)
|
||||
self.assertIn('10,000.000', shipment.report_linkage_summary_estimated)
|
||||
summary_rows = shipment._get_report_linkage_summary_rows()
|
||||
freight_rows = [
|
||||
row for row in summary_rows
|
||||
if row[0] == 'Costs' and row[1] == 'Maritime freight']
|
||||
self.assertEqual(len(freight_rows), 1)
|
||||
self.assertEqual(freight_rows[0][2], Decimal('-25'))
|
||||
self.assertIn('P-10', shipment.report_linkage_movement_references)
|
||||
self.assertIn('S-20', shipment.report_linkage_movement_references)
|
||||
self.assertIn('100 MT', shipment.report_linkage_movement_quantities)
|
||||
|
||||
Reference in New Issue
Block a user