From d2a5982e48c6daeee4d3952098da8048e7aba407 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Fri, 15 Feb 2019 16:59:08 +0100 Subject: [PATCH] IDEMPIERE-1752 fix problem with CostAdjustmentCalloutFactory --- .../callout/CostAdjustmentCalloutFactory.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/org.adempiere.base.callout/src/org/adempiere/base/callout/CostAdjustmentCalloutFactory.java b/org.adempiere.base.callout/src/org/adempiere/base/callout/CostAdjustmentCalloutFactory.java index 322ddcc852..37f4daf7e2 100644 --- a/org.adempiere.base.callout/src/org/adempiere/base/callout/CostAdjustmentCalloutFactory.java +++ b/org.adempiere.base.callout/src/org/adempiere/base/callout/CostAdjustmentCalloutFactory.java @@ -20,6 +20,7 @@ import org.adempiere.base.IColumnCallout; import org.adempiere.base.IColumnCalloutFactory; import org.compiere.model.GridField; import org.compiere.model.GridTab; +import org.compiere.model.GridTable; import org.compiere.model.I_M_InventoryLine; import org.compiere.model.MAcctSchema; import org.compiere.model.MClient; @@ -66,7 +67,15 @@ public class CostAdjustmentCalloutFactory implements IColumnCalloutFactory { @Override public String start(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value, Object oldValue) { - MInventory inventory = MInventory.get(ctx, (Integer) mTab.getValue("M_Inventory_ID")); + String trxName = null; + if ( mTab != null + && mTab.getTableModel() != null) { + GridTable gt = mTab.getTableModel(); + if (gt.isImporting()) { + trxName = gt.get_TrxName(); + } + } + MInventory inventory = new MInventory(ctx, (Integer) mTab.getValue("M_Inventory_ID"), trxName); if (MDocType.DOCSUBTYPEINV_CostAdjustment.equals(inventory.getC_DocType().getDocSubTypeInv())) { String costingMethod = inventory.getCostingMethod(); if (value == null) { @@ -121,7 +130,15 @@ public class CostAdjustmentCalloutFactory implements IColumnCalloutFactory { @Override public String start(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value, Object oldValue) { - MInventory inventory = MInventory.get(ctx, (Integer) mTab.getValue("M_Inventory_ID")); + String trxName = null; + if ( mTab != null + && mTab.getTableModel() != null) { + GridTable gt = mTab.getTableModel(); + if (gt.isImporting()) { + trxName = gt.get_TrxName(); + } + } + MInventory inventory = new MInventory(ctx, (Integer) mTab.getValue("M_Inventory_ID"), trxName); if (MDocType.DOCSUBTYPEINV_CostAdjustment.equals(inventory.getC_DocType().getDocSubTypeInv())) { String costingMethod = inventory.getCostingMethod(); Object productValue = mTab.getValue(I_M_InventoryLine.COLUMNNAME_M_Product_ID);