diff --git a/org.adempiere.base/src/org/compiere/model/MJournal.java b/org.adempiere.base/src/org/compiere/model/MJournal.java index 625de44474..e47b50d7f2 100644 --- a/org.adempiere.base/src/org/compiere/model/MJournal.java +++ b/org.adempiere.base/src/org/compiere/model/MJournal.java @@ -332,6 +332,10 @@ public class MJournal extends X_GL_Journal implements DocAction if (getGL_Category_ID() == 0 && getC_DocType_ID() > 0) setGL_Category_ID(MDocType.get(getCtx(), getC_DocType_ID()).getGL_Category_ID()); + if (getC_AcctSchema_ID() == 0) + setC_AcctSchema_ID(MClientInfo.get(getCtx(), getAD_Client_ID()).getC_AcctSchema1_ID()); + if (getC_ConversionType_ID() == 0) + setC_ConversionType_ID(MConversionType.getDefault(getAD_Client_ID())); // IDEMPIERE-63 // for documents that can be reactivated we cannot allow changing diff --git a/org.adempiere.base/src/org/compiere/model/MJournalLine.java b/org.adempiere.base/src/org/compiere/model/MJournalLine.java index b4b84616d3..e5ab2b88e9 100644 --- a/org.adempiere.base/src/org/compiere/model/MJournalLine.java +++ b/org.adempiere.base/src/org/compiere/model/MJournalLine.java @@ -294,6 +294,16 @@ public class MJournalLine extends X_GL_JournalLine log.saveError("ParentComplete", Msg.translate(getCtx(), "GL_JournalLine")); return false; } + + if (getAD_Org_ID() <= 0) // Set Line Org to Doc Org if still not set + setAD_Org_ID(getParent().getAD_Org_ID()); + if (getLine() == 0) + setLine(DB.getSQLValueEx(get_TrxName(), "SELECT COALESCE(MAX(Line), 0) + 10 FROM GL_JournalLine WHERE GL_Journal_ID = ?", getGL_Journal_ID())); + if (getC_Currency_ID() == 0) + setC_Currency_ID(getParent().getC_Currency_ID()); + if (getC_ConversionType_ID() == 0) + setC_ConversionType_ID(getParent().getC_ConversionType_ID()); + // idempiere 344 - nmicoud if (!getOrCreateCombination()) return false; @@ -305,9 +315,6 @@ public class MJournalLine extends X_GL_JournalLine fillDimensionsFromCombination(); // end idempiere 344 - nmicoud - if (getLine() == 0) - setLine(DB.getSQLValueEx(get_TrxName(), "SELECT COALESCE(MAX(Line), 0) + 10 FROM GL_JournalLine WHERE GL_Journal_ID = ?", getGL_Journal_ID())); - // Acct Amts BigDecimal rate = getCurrencyRate(); BigDecimal amt = rate.multiply(getAmtSourceDr()); @@ -318,11 +325,7 @@ public class MJournalLine extends X_GL_JournalLine if (amt.scale() > getPrecision()) amt = amt.setScale(getPrecision(), RoundingMode.HALF_UP); setAmtAcctCr(amt); - // Set Line Org to Doc Org if still not set - if(getAD_Org_ID() <= 0) - { - setAD_Org_ID(getParent().getAD_Org_ID()); - } + return true; } // beforeSave diff --git a/org.adempiere.base/src/org/compiere/model/PO.java b/org.adempiere.base/src/org/compiere/model/PO.java index ba438a998a..7d5ee0fe06 100644 --- a/org.adempiere.base/src/org/compiere/model/PO.java +++ b/org.adempiere.base/src/org/compiere/model/PO.java @@ -2049,33 +2049,6 @@ public abstract class PO } } - // Organization Check - if (getAD_Org_ID() == 0 - && (get_AccessLevel() == ACCESSLEVEL_ORG - || (get_AccessLevel() == ACCESSLEVEL_CLIENTORG - && MClientShare.isOrgLevelOnly(getAD_Client_ID(), get_Table_ID())))) - { - log.saveError("FillMandatory", Msg.getElement(getCtx(), "AD_Org_ID")); - return false; - } - // Should be Org 0 - if (getAD_Org_ID() != 0) - { - boolean reset = get_AccessLevel() == ACCESSLEVEL_SYSTEM; - if (!reset && MClientShare.isClientLevelOnly(getAD_Client_ID(), get_Table_ID())) - { - reset = get_AccessLevel() == ACCESSLEVEL_CLIENT - || get_AccessLevel() == ACCESSLEVEL_SYSTEMCLIENT - || get_AccessLevel() == ACCESSLEVEL_ALL - || get_AccessLevel() == ACCESSLEVEL_CLIENTORG; - } - if (reset) - { - log.warning("Set Org to 0"); - setAD_Org_ID(0); - } - } - Trx localTrx = null; Trx trx = null; Savepoint savepoint = null; @@ -2172,6 +2145,34 @@ public abstract class PO } return false; } + + // Organization Check + if (getAD_Org_ID() == 0 + && (get_AccessLevel() == ACCESSLEVEL_ORG + || (get_AccessLevel() == ACCESSLEVEL_CLIENTORG + && MClientShare.isOrgLevelOnly(getAD_Client_ID(), get_Table_ID())))) + { + log.saveError("FillMandatory", Msg.getElement(getCtx(), "AD_Org_ID")); + return false; + } + // Should be Org 0 + if (getAD_Org_ID() != 0) + { + boolean reset = get_AccessLevel() == ACCESSLEVEL_SYSTEM; + if (!reset && MClientShare.isClientLevelOnly(getAD_Client_ID(), get_Table_ID())) + { + reset = get_AccessLevel() == ACCESSLEVEL_CLIENT + || get_AccessLevel() == ACCESSLEVEL_SYSTEMCLIENT + || get_AccessLevel() == ACCESSLEVEL_ALL + || get_AccessLevel() == ACCESSLEVEL_CLIENTORG; + } + if (reset) + { + log.warning("Set Org to 0"); + setAD_Org_ID(0); + } + } + // Save if (newRecord) {