From e4590e61775c8b9cf0975e934d616f6baa5831a0 Mon Sep 17 00:00:00 2001 From: laurentbarontini Date: Tue, 14 Jul 2026 10:41:50 +0200 Subject: [PATCH] Polish linkage report table spacing --- modules/purchase_trade/stock.py | 14 ++++++---- modules/purchase_trade/tests/test_module.py | 2 +- modules/stock/linkage.fodt | 31 +++++++++++++++------ 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/modules/purchase_trade/stock.py b/modules/purchase_trade/stock.py index 8df4610..c6053f6 100755 --- a/modules/purchase_trade/stock.py +++ b/modules/purchase_trade/stock.py @@ -1721,6 +1721,8 @@ class ShipmentIn(metaclass=PoolMeta): getattr(product, 'name', None) or cls._report_rec_name(product) or 'Fee') + if label.startswith('[') and '] ' in label: + label = label.split('] ', 1)[1] return label def _get_report_linkage_summary_rows(self): @@ -1844,10 +1846,10 @@ class ShipmentIn(metaclass=PoolMeta): -self._report_line_amount(line))) for fee in self._get_report_linkage_fees(): rows.append(self._get_report_linkage_fee_detail_row(fee)) - total = sum((row[-1] for row in rows), Decimal('0')) + total = sum((row[7] for row in rows), Decimal('0')) if rows: - rows.append(('A', 'Total', '', '', '', '', total, total)) - rows.append(('P&L', '', '', '', '', '', total, total)) + rows.append(('A', 'Total', '', '', '', '', total, total, 'total')) + rows.append(('P&L', '', '', '', '', '', total, total, 'pnl')) return rows def _get_report_linkage_detail_row(self, group, label, trade, line, amount): @@ -1867,6 +1869,7 @@ class ShipmentIn(metaclass=PoolMeta): quantity, amount, amount, + 'line', ) def _get_report_linkage_fee_detail_row(self, fee): @@ -1888,7 +1891,7 @@ class ShipmentIn(metaclass=PoolMeta): quantity = self._report_line_quantity(trade_line) return ( 'A', - self._report_rec_name(product) or 'Fee', + self._report_linkage_fee_label(fee), self._report_rec_name(getattr(fee, 'supplier', None)), self._report_number(trade), ' '.join(part for part in [ @@ -1898,6 +1901,7 @@ class ShipmentIn(metaclass=PoolMeta): self._format_report_quantity(quantity or 0), amount, amount, + 'fee', ) @classmethod @@ -2168,7 +2172,7 @@ class ShipmentIn(metaclass=PoolMeta): return self._report_table_rows( self._get_report_linkage_detail_rows(), ('group', 'cost_type', 'counterpart', 'source', 'unit_price', - 'quantity', 'estimated', 'validated'), + 'quantity', 'estimated', 'validated', 'kind'), {'estimated', 'validated'}) def get_rec_name(self, name=None): diff --git a/modules/purchase_trade/tests/test_module.py b/modules/purchase_trade/tests/test_module.py index c80c34a..d2e287f 100644 --- a/modules/purchase_trade/tests/test_module.py +++ b/modules/purchase_trade/tests/test_module.py @@ -6669,7 +6669,7 @@ description shipment.bl_date = datetime.date(2026, 4, 30) freight_product = SimpleNamespace( rec_name='[Maritime Freight] Maritime freight', - name='Maritime freight') + name='[Maritime Freight] Maritime freight') shipment.fees = [ SimpleNamespace( id=201, product=freight_product, price=Decimal('10'), diff --git a/modules/stock/linkage.fodt b/modules/stock/linkage.fodt index f817030..b9c0161 100644 --- a/modules/stock/linkage.fodt +++ b/modules/stock/linkage.fodt @@ -1147,8 +1147,10 @@ + + @@ -1184,26 +1186,29 @@ - - + + + - - + + - + + + @@ -1227,7 +1232,7 @@ <shipment.report_linkage_title or ''> -/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoM +/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoM DAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsN FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAAR CAAyAqADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAA @@ -1436,14 +1441,17 @@ <if test="row['kind'] == 'pnl'"> <row['group']><row['cost_type']><row['estimated']><row['validated']> </if> -<if test="row['kind'] != 'pnl'"> +<if test="row['kind'] == 'cost'"> +<row['group']><row['cost_type']><row['estimated']><row['validated']> +</if> +<if test="row['kind'] != 'pnl' and row['kind'] != 'cost'"> <row['group']><row['cost_type']><row['estimated']><row['validated']> </if> </for> - + 3- Loading and Discharge movements @@ -1478,7 +1486,7 @@ <shipment.report_linkage_title or ''> -/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoM +/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoM DAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsN FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAAR CAAyAqADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAA @@ -1684,7 +1692,12 @@ GroupCost TypeCounterpartSourceUnit PriceQuantityEstimatedValidated <for each="row in shipment.report_linkage_detail_rows"> +<if test="row['kind'] == 'pnl'"> +<row['group']><row['cost_type']><row['counterpart']><row['source']><row['unit_price']><row['quantity']><row['estimated']><row['validated']> +</if> +<if test="row['kind'] != 'pnl'"> <row['group']><row['cost_type']><row['counterpart']><row['source']><row['unit_price']><row['quantity']><row['estimated']><row['validated']> +</if> </for>