From 801e53f9536c5bd24ad35477a4d793ea547f1cfa Mon Sep 17 00:00:00 2001 From: laurentbarontini Date: Sun, 7 Jun 2026 05:45:21 +0200 Subject: [PATCH] Shipment creation bug --- modules/purchase_trade/stock.py | 9 ++++++++- modules/purchase_trade/tests/test_module.py | 11 +++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/modules/purchase_trade/stock.py b/modules/purchase_trade/stock.py index ed0f08b..37654ad 100755 --- a/modules/purchase_trade/stock.py +++ b/modules/purchase_trade/stock.py @@ -791,6 +791,13 @@ class ShipmentIn(metaclass=PoolMeta): @classmethod def write(cls, *args): + new_args = cls._normalize_transport_write_args(args) + if not new_args: + return + return super().write(*new_args) + + @classmethod + def _normalize_transport_write_args(cls, args): new_args = [] for index in range(0, len(args), 2): records = args[index] @@ -799,7 +806,7 @@ class ShipmentIn(metaclass=PoolMeta): new_args.extend([ [record], cls._normalize_transport_values(values, record)]) - super().write(*new_args) + return new_args @classmethod def _stock_move_origin(cls, move): diff --git a/modules/purchase_trade/tests/test_module.py b/modules/purchase_trade/tests/test_module.py index 1a7d0d8..ca906b6 100644 --- a/modules/purchase_trade/tests/test_module.py +++ b/modules/purchase_trade/tests/test_module.py @@ -5427,6 +5427,17 @@ class PurchaseTradeTestCase(ModuleTestCase): 'vessel': None, }) + def test_shipment_in_write_ignores_empty_record_groups(self): + 'shipment write normalization keeps empty internal writes as no-op' + ShipmentIn = Pool().get('stock.shipment.in') + + self.assertEqual( + ShipmentIn._normalize_transport_write_args(( + [], + {'cost_price': Decimal('12.34')}, + )), + []) + def test_invoice_report_transportation_uses_truck_label(self): 'invoice_melya Transportation displays By Truck for truck shipments' Invoice = Pool().get('account.invoice')