diff --git a/org.adempiere.base/src/org/compiere/model/PO.java b/org.adempiere.base/src/org/compiere/model/PO.java index 83bb9c1e3d..430dd1fd48 100644 --- a/org.adempiere.base/src/org/compiere/model/PO.java +++ b/org.adempiere.base/src/org/compiere/model/PO.java @@ -1989,6 +1989,7 @@ public abstract class PO */ public boolean save() { + checkValidContext(); CLogger.resetLast(); boolean newRecord = is_new(); // save locally as load resets if (!newRecord && !is_Changed()) @@ -3107,6 +3108,7 @@ public abstract class PO */ public boolean delete (boolean force) { + checkValidContext(); CLogger.resetLast(); if (is_new()) return true; @@ -4670,4 +4672,10 @@ public abstract class PO log.saveError(msg, info); } } + + private void checkValidContext() { + if (getCtx().size() == 0) + throw new AdempiereException("Context lost"); + } + } // PO