From 23a3e30cf69a433740135468f5fac1407b0ebae9 Mon Sep 17 00:00:00 2001
From: Johannes Hoermann <j.hoermann@adito.de>
Date: Thu, 28 Mar 2019 08:13:31 +0100
Subject: [PATCH] fix Productprice

---
 entity/Productprice_entity/Productprice_entity.aod        | 5 ++++-
 entity/Productprice_entity/afterOperatingState.js         | 7 +++++++
 .../entityfields/currency/valueProcess.js                 | 8 ++++++++
 .../entityfields/pricelist/valueProcess.js                | 8 ++++++++
 4 files changed, 27 insertions(+), 1 deletion(-)
 create mode 100644 entity/Productprice_entity/afterOperatingState.js
 create mode 100644 entity/Productprice_entity/entityfields/currency/valueProcess.js
 create mode 100644 entity/Productprice_entity/entityfields/pricelist/valueProcess.js

diff --git a/entity/Productprice_entity/Productprice_entity.aod b/entity/Productprice_entity/Productprice_entity.aod
index c4538d9a76..dc37cf42d1 100644
--- a/entity/Productprice_entity/Productprice_entity.aod
+++ b/entity/Productprice_entity/Productprice_entity.aod
@@ -4,6 +4,7 @@
   <title>Prices</title>
   <majorModelMode>DISTRIBUTED</majorModelMode>
   <documentation>%aditoprj%/entity/Productprice_entity/documentation.adoc</documentation>
+  <afterOperatingState>%aditoprj%/entity/Productprice_entity/afterOperatingState.js</afterOperatingState>
   <recordContainer>db</recordContainer>
   <entityFields>
     <entityField>
@@ -18,6 +19,7 @@
       <title>Currency</title>
       <consumer>KeywordCurrencies</consumer>
       <mandatory v="true" />
+      <valueProcess>%aditoprj%/entity/Productprice_entity/entityfields/currency/valueProcess.js</valueProcess>
       <displayValueProcess>%aditoprj%/entity/Productprice_entity/entityfields/currency/displayValueProcess.js</displayValueProcess>
     </entityField>
     <entityField>
@@ -48,7 +50,7 @@
       <consumer>Products</consumer>
       <linkedContext>Product</linkedContext>
       <mandatory v="true" />
-      <state>AUTO</state>
+      <state>READONLY</state>
       <valueProcess>%aditoprj%/entity/Productprice_entity/entityfields/product_id/valueProcess.js</valueProcess>
       <displayValueProcess>%aditoprj%/entity/Productprice_entity/entityfields/product_id/displayValueProcess.js</displayValueProcess>
     </entityField>
@@ -93,6 +95,7 @@
       <state>AUTO</state>
       <stateProcess>%aditoprj%/entity/Productprice_entity/entityfields/pricelist/stateProcess.js</stateProcess>
       <titleProcess>%aditoprj%/entity/Productprice_entity/entityfields/pricelist/titleProcess.js</titleProcess>
+      <valueProcess>%aditoprj%/entity/Productprice_entity/entityfields/pricelist/valueProcess.js</valueProcess>
       <displayValueProcess>%aditoprj%/entity/Productprice_entity/entityfields/pricelist/displayValueProcess.js</displayValueProcess>
       <onValidation>%aditoprj%/entity/Productprice_entity/entityfields/pricelist/onValidation.js</onValidation>
     </entityField>
diff --git a/entity/Productprice_entity/afterOperatingState.js b/entity/Productprice_entity/afterOperatingState.js
new file mode 100644
index 0000000000..5541dfea33
--- /dev/null
+++ b/entity/Productprice_entity/afterOperatingState.js
@@ -0,0 +1,7 @@
+import("system.neon");
+import("system.vars");
+
+if(vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_VIEW) 
+{
+    neon.refresh();
+}
diff --git a/entity/Productprice_entity/entityfields/currency/valueProcess.js b/entity/Productprice_entity/entityfields/currency/valueProcess.js
new file mode 100644
index 0000000000..081cebb3e4
--- /dev/null
+++ b/entity/Productprice_entity/entityfields/currency/valueProcess.js
@@ -0,0 +1,8 @@
+import("system.result");
+import("system.neon");
+import("system.vars");
+
+if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
+{
+    result.string("EUR");
+}
\ No newline at end of file
diff --git a/entity/Productprice_entity/entityfields/pricelist/valueProcess.js b/entity/Productprice_entity/entityfields/pricelist/valueProcess.js
new file mode 100644
index 0000000000..f9c9524ced
--- /dev/null
+++ b/entity/Productprice_entity/entityfields/pricelist/valueProcess.js
@@ -0,0 +1,8 @@
+import("system.result");
+import("system.neon");
+import("system.vars");
+
+if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
+{
+    result.string("02553fc7-4611-4914-8ff5-0b7c4e7531c9");
+}
\ No newline at end of file
-- 
GitLab