From f8fbf5f3bb97a39b44a09e771aa4d47e829cc760 Mon Sep 17 00:00:00 2001 From: hengsin Date: Tue, 17 Aug 2021 22:07:13 +0800 Subject: [PATCH] IDEMPIERE-1351 Quick Entry when Field can not zoom to 2 different windows (#829) --- .../src/org/compiere/model/GridTab.java | 48 +++++++++++++++++++ .../adwindow/AbstractADWindowContent.java | 5 +- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/GridTab.java b/org.adempiere.base/src/org/compiere/model/GridTab.java index 98f4c11d37..7e09ff0f09 100644 --- a/org.adempiere.base/src/org/compiere/model/GridTab.java +++ b/org.adempiere.base/src/org/compiere/model/GridTab.java @@ -2631,6 +2631,12 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable } if (changingRow && keyCalloutDelayed != null) processCallout(keyCalloutDelayed); + + //set isSOTrx context + if (changingRow) { + setIsSOTrxContext(); + } + loadDependentInfo(); if (!fireEvents) // prevents informing twice @@ -2668,6 +2674,48 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable return m_currentRow; } // setCurrentRow + private void setIsSOTrxContext() { + final String IsSOTrx = "IsSOTrx"; + final String C_DocType_ID = "C_DocType_ID"; + final String C_DocTypeTarget_ID = "C_DocTypeTarget_ID"; + if (getField(IsSOTrx) != null || getField(C_DocType_ID) != null || getField(C_DocTypeTarget_ID) != null) { + String isSOTrx = null; + GridField field = getField(IsSOTrx); + if (field != null && field.getValue() != null) { + Object value = field.getValue(); + if (value instanceof Boolean) { + isSOTrx = ((Boolean) value).booleanValue() ? "Y" : "N"; + } else if (value instanceof String) { + isSOTrx = (String) value; + } + } + if (isSOTrx == null) { + field = getField(C_DocType_ID); + if (field != null && field.getValue() != null) { + int docTypeId = ((Number)field.getValue()).intValue(); + if (docTypeId > 0) { + isSOTrx = MDocType.get(docTypeId).isSOTrx() ? "Y" : "N"; + } + } + } + if (isSOTrx == null) { + field = getField(C_DocTypeTarget_ID); + if (field != null && field.getValue() != null) { + int docTypeId = ((Number)field.getValue()).intValue(); + if (docTypeId > 0) { + isSOTrx = MDocType.get(docTypeId).isSOTrx() ? "Y" : "N"; + } + } + } + if (isSOTrx != null) { + Env.setContext(Env.getCtx(), getWindowNo(), getTabNo(), IsSOTrx, isSOTrx); + if (m_vo.TabNo == 0) { + Env.setContext(Env.getCtx(), getWindowNo(), IsSOTrx, isSOTrx); + } + } + } + } + /** * Set current row - used for deleteSelection diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java index 23803224a1..b787629d51 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java @@ -380,8 +380,9 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements gridTab.getTableModel().setChanged(false); adTabbox.setSelectedIndex(0); - // all fields context for window is clear at AbstractADTab.prepareContext, set again IsSOTrx for window - Env.setContext(ctx, curWindowNo, "IsSOTrx", gridWindow.isSOTrx()); + // set again IsSOTrx for window if context for window is clear at AbstractADTab.prepareContext, + if (Env.getContext(ctx, curWindowNo, "IsSOTrx", true) == null) + Env.setContext(ctx, curWindowNo, "IsSOTrx", gridWindow.isSOTrx()); toolbar.enableTabNavigation(adTabbox.getTabCount() > 1); toolbar.enableFind(true); adTabbox.evaluate(null);