Add asset if new GTIN product has been created

This commit is contained in:
Dirk Jahnke 2022-04-13 15:51:31 +02:00
parent 4b7234fa68
commit c7da144f5e
1 changed files with 6 additions and 0 deletions

View File

@ -65,4 +65,10 @@ def asset_from_gtin(request):
print(f'ERROR: Could not create asset for gtin={gtin}')
else:
print(f'Create new product: {product.name}, brand={product.brand}, gtin={product.gtin}')
asset = Asset.objects.create(
named_id='A-' + product.gtin,
description=product.name,
created_by=request.user,
changed_by=request.user)
asset.save()
return HttpResponseRedirect(reverse('asset:list'))