Use isinstance() to check if origin points to a purchase.
If origin only points to a model without a specific ID, then 'origin' evaluates to True but is not an object (but str) so using origin.__name__ crashes.
This commit is contained in:
parent
0224697827
commit
f98cf7464d
|
@ -303,6 +303,7 @@ class EdiShipmentInLine(ModelSQL, ModelView):
|
|||
pool = Pool()
|
||||
Barcode = pool.get('product.code')
|
||||
REF = pool.get('edi.shipment.in.reference')
|
||||
Purchase = pool.get('purchase.purchase')
|
||||
|
||||
domain = [('number', '=', self.code)]
|
||||
barcode = Barcode.search(domain, limit=1)
|
||||
|
@ -312,8 +313,7 @@ class EdiShipmentInLine(ModelSQL, ModelView):
|
|||
self.product = product
|
||||
|
||||
purchases = [x.origin for x in edi_shipment.references if
|
||||
x.type_ == 'ON' and x.origin
|
||||
and x.origin.__name__ == 'purchase.purchase']
|
||||
x.type_ == 'ON' and isinstance(x.origin, Purchase)]
|
||||
|
||||
self.references = []
|
||||
for purchase in purchases:
|
||||
|
|
Loading…
Reference in New Issue