From 7b1c9322f9a669737402a214735b8e644a7fd8a9 Mon Sep 17 00:00:00 2001 From: hengsin Date: Thu, 2 Dec 2021 09:23:36 +0800 Subject: [PATCH] IDEMPIERE-5066 Order Line Create Production not visible in the process toolbar dropdown (#1021) --- .../org/compiere/util/DefaultEvaluatee.java | 18 +++++++++++++++-- .../test/base/LogicExpressionTest.java | 20 +++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/util/DefaultEvaluatee.java b/org.adempiere.base/src/org/compiere/util/DefaultEvaluatee.java index 771de30242..cd52b171ae 100644 --- a/org.adempiere.base/src/org/compiere/util/DefaultEvaluatee.java +++ b/org.adempiere.base/src/org/compiere/util/DefaultEvaluatee.java @@ -135,7 +135,15 @@ public class DefaultEvaluatee implements Evaluatee { { po = s_ReferenceCache.get(key); if (po != null && po.get_ID() == id) - refValue = po.get_ValueAsString(foreignColumn); + { + Object value = po.get_Value(foreignColumn); + if (value == null) + refValue = ""; + else if (value instanceof Boolean) + refValue = (Boolean)value ? "Y" : "N"; + else + refValue = value.toString(); + } else po = null; } @@ -145,7 +153,13 @@ public class DefaultEvaluatee implements Evaluatee { if (po != null && po.get_ID() == id) { s_ReferenceCache.put(key, po); - refValue = po.get_ValueAsString(foreignColumn); + Object value = po.get_Value(foreignColumn); + if (value == null) + refValue = ""; + else if (value instanceof Boolean) + refValue = (Boolean)value ? "Y" : "N"; + else + refValue = value.toString(); } } return refValue; diff --git a/org.idempiere.test/src/org/idempiere/test/base/LogicExpressionTest.java b/org.idempiere.test/src/org/idempiere/test/base/LogicExpressionTest.java index a7a6918167..d595788433 100644 --- a/org.idempiere.test/src/org/idempiere/test/base/LogicExpressionTest.java +++ b/org.idempiere.test/src/org/idempiere/test/base/LogicExpressionTest.java @@ -42,6 +42,7 @@ import org.compiere.model.MTable; import org.compiere.model.PO; import org.compiere.model.Query; import org.compiere.util.DB; +import org.compiere.util.DefaultEvaluatee; import org.compiere.util.Env; import org.compiere.util.Evaluatee; import org.compiere.util.LegacyLogicEvaluator; @@ -574,6 +575,25 @@ public class LogicExpressionTest extends AbstractTestCase { assertTrue(LegacyLogicEvaluator.evaluateLogic(evaluatee, expr)); } + @Test + public void testNestedProperty() { + String expr = "@Processed@=Y & @M_Product_ID.IsBOM@=Y"; + Env.setContext(Env.getCtx(), 1, "Processed", (String)null); + assertFalse(LegacyLogicEvaluator.evaluateLogic(new DefaultEvaluatee(null, 1, 0), expr)); + + int pchair = 133; + Env.setContext(Env.getCtx(), 1, "Processed", "Y"); + Env.setContext(Env.getCtx(), 1, "M_Product_ID", pchair); + assertTrue(LegacyLogicEvaluator.evaluateLogic(new DefaultEvaluatee(null, 1, 0), expr)); + + Env.setContext(Env.getCtx(), 1, "Processed", (String)null); + assertFalse(LogicEvaluator.evaluateLogic(new DefaultEvaluatee(null, 1, 0), expr)); + + Env.setContext(Env.getCtx(), 1, "Processed", "Y"); + Env.setContext(Env.getCtx(), 1, "M_Product_ID", pchair); + assertTrue(LogicEvaluator.evaluateLogic(new DefaultEvaluatee(null, 1, 0), expr)); + } + private static class ContextEvaluatee implements Evaluatee { @Override