From e184da898fd60bf021b40feaffc351c95bcbacf0 Mon Sep 17 00:00:00 2001 From: laurentbarontini Date: Tue, 14 Jul 2026 16:51:10 +0200 Subject: [PATCH] Linkage --- modules/purchase_trade/__init__.py | 1 + modules/purchase_trade/stock.py | 21 +- modules/purchase_trade/stock.xml | 13 +- modules/purchase_trade/tests/test_module.py | 8 +- modules/stock/.~lock.linkage.fodt# | 1 - modules/stock/linkage.fodt | 1336 ++++++++++++++----- 6 files changed, 1045 insertions(+), 335 deletions(-) delete mode 100644 modules/stock/.~lock.linkage.fodt# diff --git a/modules/purchase_trade/__init__.py b/modules/purchase_trade/__init__.py index d13a854..15f049a 100755 --- a/modules/purchase_trade/__init__.py +++ b/modules/purchase_trade/__init__.py @@ -366,5 +366,6 @@ def register(): stock.ShipmentPackingListReport, stock.ShipmentLinkageReport, stock.LotReportLinkageReport, + stock.LotReportLinkageFinalReport, module='purchase_trade', type_='report') diff --git a/modules/purchase_trade/stock.py b/modules/purchase_trade/stock.py index ffd8929..32b7722 100755 --- a/modules/purchase_trade/stock.py +++ b/modules/purchase_trade/stock.py @@ -4440,10 +4440,11 @@ class LinkageTemplateReport(ShipmentTemplateReportMixin, BaseSupplierShipping): class LotReportLinkageRecord: - def __init__(self, lot, lot_report=None): + def __init__(self, lot, lot_report=None, linkage_status='PROVISIONAL'): self.lot = lot self.lot_report = lot_report self.id = getattr(lot_report, 'id', None) or getattr(lot, 'id', None) + self.report_linkage_status = linkage_status @property def rec_name(self): @@ -4573,7 +4574,14 @@ class LotReportLinkageRecord: _get_report_linkage_fee_detail_row = ( ShipmentIn._get_report_linkage_fee_detail_row) - report_linkage_title = ShipmentIn.report_linkage_title + @property + def report_linkage_title(self): + title = ShipmentIn.report_linkage_title.fget(self) + status = getattr(self, 'report_linkage_status', None) + if status: + title = ' - '.join(part for part in [title, status] if part) + return title + report_linkage_desk = ShipmentIn.report_linkage_desk report_linkage_book = ShipmentIn.report_linkage_book report_linkage_strategy = ShipmentIn.report_linkage_strategy @@ -4650,6 +4658,7 @@ class LotReportLinkageRecord: class LotReportLinkageReport(LinkageTemplateReport): __name__ = 'lot.report.linkage' + linkage_status = 'PROVISIONAL' @classmethod def _get_records(cls, ids, model, data): @@ -4665,10 +4674,16 @@ class LotReportLinkageReport(LinkageTemplateReport): if not lot: raise UserError( 'Linkage report needs a physical lot on the selected line.') - linkage_records.append(LotReportLinkageRecord(lot, record)) + linkage_records.append(LotReportLinkageRecord( + lot, record, linkage_status=cls.linkage_status)) return linkage_records +class LotReportLinkageFinalReport(LotReportLinkageReport): + __name__ = 'lot.report.linkage.final' + linkage_status = 'FINAL' + + class ShipmentCOOReport(ShipmentTemplateReportMixin, BaseSupplierShipping): __name__ = 'stock.shipment.in.coo' diff --git a/modules/purchase_trade/stock.xml b/modules/purchase_trade/stock.xml index 2e3ce9e..f85e235 100755 --- a/modules/purchase_trade/stock.xml +++ b/modules/purchase_trade/stock.xml @@ -274,7 +274,7 @@ this repository contains the full copyright notices and license terms. --> - Linkage + Linkage provisional lot.report lot.report.linkage stock/linkage.fodt @@ -284,6 +284,17 @@ this repository contains the full copyright notices and license terms. --> lot.report,-1 + + Linkage final + lot.report + lot.report.linkage.final + stock/linkage.fodt + + + form_print + lot.report,-1 + + Update with SoF PDF diff --git a/modules/purchase_trade/tests/test_module.py b/modules/purchase_trade/tests/test_module.py index 35c5e33..d070683 100644 --- a/modules/purchase_trade/tests/test_module.py +++ b/modules/purchase_trade/tests/test_module.py @@ -6906,7 +6906,13 @@ description physical_lot, lot_report) self.assertEqual( - record.report_linkage_title, 'Linkage P-10/S-20 26.0001') + record.report_linkage_title, + 'Linkage P-10/S-20 26.0001 - PROVISIONAL') + final_record = stock_module.LotReportLinkageRecord( + physical_lot, lot_report, linkage_status='FINAL') + self.assertEqual( + final_record.report_linkage_title, + 'Linkage P-10/S-20 26.0001 - FINAL') self.assertEqual(record.report_linkage_bl_date, 'Thursday, April 30, 2026') self.assertIn('Purchases', record.report_linkage_summary_groups) self.assertIn('Sales', record.report_linkage_summary_groups) diff --git a/modules/stock/.~lock.linkage.fodt# b/modules/stock/.~lock.linkage.fodt# deleted file mode 100644 index 326ddf3..0000000 --- a/modules/stock/.~lock.linkage.fodt# +++ /dev/null @@ -1 +0,0 @@ -,PC_LO/baron,PC_LO,14.07.2026 15:18,file:///C:/Users/baron/AppData/Roaming/LibreOffice/4; \ No newline at end of file diff --git a/modules/stock/linkage.fodt b/modules/stock/linkage.fodt index b9c0161..8ee8c72 100644 --- a/modules/stock/linkage.fodt +++ b/modules/stock/linkage.fodt @@ -1,29 +1,29 @@ - LibreOffice/7.6.0.3$Windows_X86_64 LibreOffice_project/69edd8b8ebc41d00b4de3915dc82f8f0fc3b6265Laurent BARONTINI2026-07-07T11:58:00Z2026-07-07T14:41:47.9550000003PT2M53S + LibreOffice/7.6.0.3$Windows_X86_64 LibreOffice_project/69edd8b8ebc41d00b4de3915dc82f8f0fc3b6265Laurent BARONTINI2026-07-07T11:58:00Z2026-07-14T15:31:13.4320000004PT15M55S - 11 + 17381 0 - 48470 - 23442 + 31159 + 15713 true false view2 - 11404 - 2521 + 1298 + 23222 0 - 11 - 48468 - 23451 + 17381 + 31157 + 33092 0 0 false - 90 - false + 140 + true false true true @@ -91,7 +91,7 @@ false false false - 2124067 + 2185667 2065993 false false @@ -160,7 +160,7 @@ - + @@ -206,8 +206,11 @@ + + + - + @@ -286,308 +289,338 @@ - + - + - + - + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - + + - + - + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + - + - + - + - + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + - + - + - + - + - + - + - + - + - + - + - + + + + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + - + - + - + - + - + - + - + - + - + - + - + - + + + + - + - + - + - + + + + - + - + - + - + - + @@ -1047,49 +1080,122 @@ + + + + + + + + - + - + + + + - + - + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + - - + + + - - + + + - - + + + + + + + + + + + + + + + @@ -1125,13 +1231,6 @@ - - - - - - - @@ -1141,98 +1240,31 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - <for each="shipment in records"> - - -<shipment.report_linkage_title or ''> -/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoM + + + + + + + + <for each="shipment in records"> + + + + + + + + + + /9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoM DAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsN FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAAR CAAyAqADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAA @@ -1425,68 +1457,477 @@ UUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFF ABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAU UUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQB//9k= - Desk<shipment.report_linkage_desk or ''>B/L Date<shipment.report_linkage_bl_date or ''> -Book<shipment.report_linkage_book or ''>Trading Unit<shipment.report_linkage_trading_unit or ''> -Strategy<shipment.report_linkage_strategy or ''>Finance user<shipment.report_linkage_finance_user or ''> - - - - -1- Financial summary ( USD )2- Information - - - -GroupCost TypeEstimatedValidated -<for each="row in shipment.report_linkage_summary_rows"> -<if test="row['kind'] == 'pnl'"> -<row['group']><row['cost_type']><row['estimated']><row['validated']> -</if> -<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 - - - -TypeReferenceCounterpartCommodityQuantityDeliveryBasisPeriod atFromTo -<for each="row in shipment.report_linkage_movement_rows"> -<row['type']><row['reference']><row['counterpart']><row['commodity']><row['quantity']><row['delivery']><row['basis']><row['period']><row['from_date']><row['to_date']> -</for> - - - - -4- Bank Information - - - -Deal<shipment.report_linkage_bank_deal or ''>Type<shipment.report_linkage_bank_type or ''>Financing Bank<shipment.report_linkage_bank_name or ''>LC Type<shipment.report_linkage_lc_type or ''>LC Number<shipment.report_linkage_lc_number or ''>LC Amount<shipment.report_linkage_lc_amount or ''>LC Expiry Date<shipment.report_linkage_lc_expiry_date or ''> - - - - -5- Pricing - - - -DealTypeTypeSymbolPeriodInput Price -<for each="row in shipment.report_linkage_pricing_rows"> -<row['deal']><row['side']><row['type']><row['symbol']><row['period']><row['input_price']> -</for> - - - - -<shipment.report_linkage_title or ''> -/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoM + + + + + + <shipment.report_linkage_title or ''> + + + + + + + + + + + Desk + + + <shipment.report_linkage_desk or ''> + + + B/L Date + + + <shipment.report_linkage_bl_date or ''> + + + + + + + + Book + + + <shipment.report_linkage_book or ''> + + + Trading Unit + + + <shipment.report_linkage_trading_unit or ''> + + + + + + + + Strategy + + + <shipment.report_linkage_strategy or ''> + + + Finance user + + + <shipment.report_linkage_finance_user or ''> + + + + + + + + + + + + 1- Financial summary ( USD ) + + + + + + 2- Information + + + + + + + + + + + + + + Group + + + Cost Type + + + Estimated + + + Validated + + + + + <for each="row in shipment.report_linkage_summary_rows"> + + + + + + + + <if test="row['kind'] == 'pnl'"> + + + + + + + + <row['group']> + + + <row['cost_type']> + + + <row['estimated']> + + + <row['validated']> + + + + + </if> + + + + + + + + <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 + + + + + + + + + + + + + + + + + + + + Type + + + Reference + + + Counterpart + + + Commodity + + + Quantity + + + Delivery + + + Basis + + + Period at + + + From + + + To + + + + + <for each="row in shipment.report_linkage_movement_rows"> + + + + + + + + + + + + + + <row['type']> + + + <row['reference']> + + + <row['counterpart']> + + + <row['commodity']> + + + <row['quantity']> + + + <row['delivery']> + + + <row['basis']> + + + <row['period']> + + + <row['from_date']> + + + <row['to_date']> + + + + + </for> + + + + + + + + + + + + + + + + + + + 4- Bank Information + + + + + + + + + + + + + + + + + Deal + <shipment.report_linkage_bank_deal or ''> + + + Type + <shipment.report_linkage_bank_type or ''> + + + Financing Bank + <shipment.report_linkage_bank_name or ''> + + + LC Type + <shipment.report_linkage_lc_type or ''> + + + LC Number + <shipment.report_linkage_lc_number or ''> + + + LC Amount + <shipment.report_linkage_lc_amount or ''> + + + LC Expiry Date + <shipment.report_linkage_lc_expiry_date or ''> + + + + + + + + + + 5- Pricing + + + + + + + + + + + + + + + + Deal + + + Type + + + Type + + + Symbol + + + Period + + + Input Price + + + + + <for each="row in shipment.report_linkage_pricing_rows"> + + + + + + + + + + <row['deal']> + + + <row['side']> + + + <row['type']> + + + <row['symbol']> + + + <row['period']> + + + <row['input_price']> + + + + + </for> + + + + + + + + + + + + + + + + + + + /9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoM DAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsN FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAAR CAAyAqADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAA @@ -1679,33 +2120,270 @@ UUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFF ABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAU UUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQB//9k= - Desk<shipment.report_linkage_desk or ''>B/L Date<shipment.report_linkage_bl_date or ''> -Book<shipment.report_linkage_book or ''>Trading Unit<shipment.report_linkage_trading_unit or ''> -Strategy<shipment.report_linkage_strategy or ''>Finance user<shipment.report_linkage_finance_user or ''> - - - - -6- Financial details ( USD ) - - - -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> - - - - -OliverGyslerJeremieCOLLOTStephaneMonnardSteveZaccarini - - </for> + + + + + + <shipment.report_linkage_title or ''> + + + + + + + + + + + Desk + + + <shipment.report_linkage_desk or ''> + + + B/L Date + + + <shipment.report_linkage_bl_date or ''> + + + + + + + + Book + + + <shipment.report_linkage_book or ''> + + + Trading Unit + + + <shipment.report_linkage_trading_unit or ''> + + + + + + + + Strategy + + + <shipment.report_linkage_strategy or ''> + + + Finance user + + + <shipment.report_linkage_finance_user or ''> + + + + + + + + + + 6- Financial details ( USD ) + + + + + + + + + + + + + + + + + + Group + + + Cost Type + + + Counterpart + + + Source + + + Unit Price + + + Quantity + + + Estimated + + + Validated + + + + + <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> + + + + + + + + + + + + + + + + + Oliver + Gysler + + + + Jeremie + COLLOT + + + + Stephane + Monnard + + + + Steve + Zaccarini + + + + + </for>