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

This commit is contained in:
Bernat Brunet 2020-10-29 14:20:57 +01:00
parent c02e7b0ee4
commit 820c1bbc3c
1 changed files with 7 additions and 0 deletions

View File

@ -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])