From 820c1bbc3c06f15c1158fd27e3537b3c2b5ba031 Mon Sep 17 00:00:00 2001 From: Bernat Brunet Date: Thu, 29 Oct 2020 14:20:57 +0100 Subject: [PATCH] Update EDI import shipments. Some times the EDI reference is not the purchase number, it's the purchase reference, so we need to search for the reference too, ensuring is unique --- shipment.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/shipment.py b/shipment.py index dac83f5..05895b7 100644 --- a/shipment.py +++ b/shipment.py @@ -241,6 +241,13 @@ class ShipmentIn(EdifactMixin, metaclass=PoolMeta): ('number', '=', purchase_num), ('state', 'in', ('processing', 'done')) ], limit=1) or [None] + if not purchase: + purchases = Purchase.search([ + ('reference', '=', purchase_num), + ('state', 'in', ('processing', 'done')) + ]) + if len(purchases) == 1: + purchase = purchase[0] if not purchase: error_msg = 'Purchase number {} not found'.format(purchase_num) serialized_segment = Serializer(control_chars).serialize([segment])