From c7da144f5e907ecb58a9a6246cf68ea289ac7f13 Mon Sep 17 00:00:00 2001 From: Dirk Jahnke Date: Wed, 13 Apr 2022 15:51:31 +0200 Subject: [PATCH] Add asset if new GTIN product has been created --- asset/views.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/asset/views.py b/asset/views.py index db60657..e15f9ba 100644 --- a/asset/views.py +++ b/asset/views.py @@ -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'))