From 0c5cee0ed39f4c57e4d8b312779137e8c51e1936 Mon Sep 17 00:00:00 2001
From: Benjamin Ulrich <b.ulrich@adito.de>
Date: Wed, 28 Oct 2020 14:44:02 +0000
Subject: [PATCH] =?UTF-8?q?[Projekt:=20Entwicklung=20-=20Neon][TicketNr.:?=
 =?UTF-8?q?=201067033][[PRODUCT]=20L=C3=B6schen=20nicht=20m=C3=B6glich]?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 entity/Product_entity/Product_entity.aod              |  1 +
 .../Product_entity/recordcontainers/db/onDBDelete.js  | 11 +++++++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/entity/Product_entity/Product_entity.aod b/entity/Product_entity/Product_entity.aod
index 5fbf1ca2f53..2a6662b6f7d 100644
--- a/entity/Product_entity/Product_entity.aod
+++ b/entity/Product_entity/Product_entity.aod
@@ -13,6 +13,7 @@
   <useFavorites v="true" />
   <iconId>VAADIN:HAMMER</iconId>
   <imageProcess>%aditoprj%/entity/Product_entity/imageProcess.js</imageProcess>
+  <usePermissions v="true" />
   <titlePlural>Products</titlePlural>
   <recordContainer>db</recordContainer>
   <entityFields>
diff --git a/entity/Product_entity/recordcontainers/db/onDBDelete.js b/entity/Product_entity/recordcontainers/db/onDBDelete.js
index 7fe2819a4da..ebe48635377 100644
--- a/entity/Product_entity/recordcontainers/db/onDBDelete.js
+++ b/entity/Product_entity/recordcontainers/db/onDBDelete.js
@@ -1,18 +1,21 @@
+import("system.vars");
 import("Workflow_lib");
 import("Context_lib");
 import("Sql_lib");
 import("Attribute_lib");
 
-newWhereIfSet("PROD2PROD.DEST_ID", "$field.PRODUCTID")
+var productId = vars.get("$local.uid");
+
+newWhereIfSet("PROD2PROD.DEST_ID", productId)
     .deleteData();
     
-newWhereIfSet("PROD2PROD.SOURCE_ID", "$field.PRODUCTID")
+newWhereIfSet("PROD2PROD.SOURCE_ID", productId)
     .deleteData();
     
-newWhereIfSet("PRODUCTPRICE.PRODUCT_ID", "$field.PRODUCTID")
+newWhereIfSet("PRODUCTPRICE.PRODUCT_ID", productId)
     .deleteData();
     
-newWhereIfSet("STOCK.PRODUCT_ID", "$field.PRODUCTID")
+newWhereIfSet("STOCK.PRODUCT_ID", productId)
     .deleteData();
     
 new AttributeRelationQuery(productId, null, ContextUtils.getCurrentContextId())
-- 
GitLab