IDEMPIERE-4727 Movement Window: a new line can be created for a movement that is completed. (#634)

* IDEMPIERE-4727 Movement Window: a new line can be created for a movement that is completed.

* IDEMPIERE-4727 Movement Window: a new line can be created for a movement that is completed.

Fix the problem also in model, to cover case when trying to add/modify lines for example via webservices

* IDEMPIERE-4727 Movement Window: a new line can be created for a movement that is completed.

Fix the problem also in model, change approach to use isProcessed instead of isComplete
This commit is contained in:
Carlos Ruiz 2021-04-08 16:40:27 +02:00 committed by GitHub
parent b22ceeabdf
commit 932ed8f498
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 348 additions and 42 deletions

View File

@ -0,0 +1,37 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-4727 Movement Window: a new line can be created for a movement that is completed.
-- Mar 16, 2021, 2:59:48 PM CET
UPDATE AD_Tab SET ReadOnlyLogic='@Processed@=Y',Updated=TO_DATE('2021-03-16 14:59:48','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Tab_ID IN (
329 /* Bank/Cash Statement > Statement Line*/ ,
200103 /* Cost Adjustment > Cost Adjustment Line*/ ,
200138 /* Customer Return > Attributes*/ ,
629 /* Customer RMA > RMA Line*/ ,
200008 /* GL Journal > Line*/ ,
160 /* GL Journal Batch > Journal*/ ,
161 /* GL Journal Batch > Line*/ ,
683 /* Internal Use Inventory > Internal Use Line*/ ,
53134 /* Internal Use Inventory > Attributes*/ ,
260 /* Inventory Move > Move Line*/ ,
750 /* Inventory Move > Attributes*/ ,
200137 /* Material Receipt > Attributes*/ ,
667 /* Move Confirmation > Line*/ ,
353 /* Payment Selection > Payment Selection Line*/ ,
256 /* Physical Inventory > Inventory Count Line*/ ,
749 /* Physical Inventory > Attributes*/ ,
320 /* Production > Production Plan*/ ,
321 /* Production > Production Line*/ ,
53345 /* Production (Single Product) > Production Line*/ ,
200224 /* Production (Single Product) > Attributes*/ ,
200016 /* Sales Order > POS Payment*/ ,
751 /* Shipment (Customer) > Attributes*/ ,
659 /* Ship/Receipt Confirm > Line*/ ,
53281 /* Vendor RMA > RMA Line*/ ,
200068 /* Payments into Batch > Lines*/
)
;
SELECT register_migration_script('202103161500_IDEMPIERE-4727.sql') FROM dual
;

View File

@ -0,0 +1,34 @@
-- IDEMPIERE-4727 Movement Window: a new line can be created for a movement that is completed.
-- Mar 16, 2021, 2:59:48 PM CET
UPDATE AD_Tab SET ReadOnlyLogic='@Processed@=Y',Updated=TO_TIMESTAMP('2021-03-16 14:59:48','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Tab_ID IN (
329 /* Bank/Cash Statement > Statement Line*/ ,
200103 /* Cost Adjustment > Cost Adjustment Line*/ ,
200138 /* Customer Return > Attributes*/ ,
629 /* Customer RMA > RMA Line*/ ,
200008 /* GL Journal > Line*/ ,
160 /* GL Journal Batch > Journal*/ ,
161 /* GL Journal Batch > Line*/ ,
683 /* Internal Use Inventory > Internal Use Line*/ ,
53134 /* Internal Use Inventory > Attributes*/ ,
260 /* Inventory Move > Move Line*/ ,
750 /* Inventory Move > Attributes*/ ,
200137 /* Material Receipt > Attributes*/ ,
667 /* Move Confirmation > Line*/ ,
353 /* Payment Selection > Payment Selection Line*/ ,
256 /* Physical Inventory > Inventory Count Line*/ ,
749 /* Physical Inventory > Attributes*/ ,
320 /* Production > Production Plan*/ ,
321 /* Production > Production Line*/ ,
53345 /* Production (Single Product) > Production Line*/ ,
200224 /* Production (Single Product) > Attributes*/ ,
200016 /* Sales Order > POS Payment*/ ,
751 /* Shipment (Customer) > Attributes*/ ,
659 /* Ship/Receipt Confirm > Line*/ ,
53281 /* Vendor RMA > RMA Line*/ ,
200068 /* Payments into Batch > Lines*/
)
;
SELECT register_migration_script('202103161500_IDEMPIERE-4727.sql') FROM dual
;

View File

@ -184,8 +184,8 @@ public class MAllocationLine extends X_C_AllocationLine
*/
protected boolean beforeSave (boolean newRecord)
{
if (newRecord && getParent().isComplete()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "C_AllocationLine"));
if (newRecord && getParent().isProcessed()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "C_AllocationHdr_ID"));
return false;
}
if (!newRecord

View File

@ -162,8 +162,8 @@ import org.compiere.util.Msg;
*/
protected boolean beforeSave (boolean newRecord)
{
if (newRecord && getParent().isComplete()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "C_BankStatementLine"));
if (newRecord && getParent().isProcessed()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "C_BankStatement_ID"));
return false;
}
// Calculate Charge = Statement - trx - Interest

View File

@ -302,8 +302,8 @@ public class MCashLine extends X_C_CashLine
*/
protected boolean beforeSave (boolean newRecord)
{
if (newRecord && getParent().isComplete()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "C_CashLine"));
if (newRecord && getParent().isProcessed()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "C_Cash_ID"));
return false;
}
// Cannot change generated Invoices

View File

@ -54,7 +54,7 @@ public class MDepositBatch extends X_C_DepositBatch
/**
*
*/
private static final long serialVersionUID = -977397802747749777L;
private static final long serialVersionUID = 7691820074981291939L;
/**
* Create & Load existing Persistent Object
@ -310,4 +310,16 @@ public class MDepositBatch extends X_C_DepositBatch
return retValue;
} // getLines
/**
* Document Status is Complete or Closed
* @return true if CO, CL or RE
*/
public boolean isComplete()
{
String ds = getDocStatus();
return DOCSTATUS_Completed.equals(ds)
|| DOCSTATUS_Closed.equals(ds)
|| DOCSTATUS_Reversed.equals(ds);
} // isComplete
} // MDepositBatch

View File

@ -36,6 +36,7 @@ import java.util.Properties;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Msg;
/**
* Bank Statement Line Model
@ -122,6 +123,11 @@ import org.compiere.util.Env;
*/
protected boolean beforeSave (boolean newRecord)
{
MDepositBatch parent = new MDepositBatch(getCtx(), getC_DepositBatch_ID(), get_TrxName());
if (newRecord && parent.isProcessed()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "C_DepositBatch_ID"));
return false;
}
// Set Line No
if (getLine() == 0)
{

View File

@ -51,7 +51,7 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction
/**
*
*/
private static final long serialVersionUID = 5270365186462536874L;
private static final long serialVersionUID = -1998947558580855224L;
/**
* Create Confirmation or return existing one
@ -841,5 +841,17 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction
{
return 0;
} // getC_Currency_ID
/**
* Document Status is Complete or Closed
* @return true if CO, CL or RE
*/
public boolean isComplete()
{
String ds = getDocStatus();
return DOCSTATUS_Completed.equals(ds)
|| DOCSTATUS_Closed.equals(ds)
|| DOCSTATUS_Reversed.equals(ds);
} // isComplete
} // MInOutConfirm

View File

@ -505,8 +505,8 @@ public class MInOutLine extends X_M_InOutLine
protected boolean beforeSave (boolean newRecord)
{
log.fine("");
if (newRecord && getParent().isComplete()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_InOutLine"));
if (newRecord && getParent().isProcessed()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_InOut_ID"));
return false;
}
if (getParent().pendingConfirmations()) {

View File

@ -182,6 +182,11 @@ public class MInOutLineConfirm extends X_M_InOutLineConfirm
*/
protected boolean beforeSave (boolean newRecord)
{
MInOutConfirm parent = new MInOutConfirm(getCtx(), getM_InOutConfirm_ID(), get_TrxName());
if (newRecord && parent.isProcessed()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_InOutConfirm_ID"));
return false;
}
// Calculate Difference = Target - Confirmed - Scrapped
BigDecimal difference = getTargetQty();
difference = difference.subtract(getConfirmedQty());

View File

@ -30,6 +30,7 @@ import org.adempiere.exceptions.AdempiereException;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.Util;
/**
@ -254,6 +255,11 @@ public class MInOutLineMA extends X_M_InOutLineMA
*/
protected boolean beforeSave (boolean newRecord)
{
MInOutLine parentline = new MInOutLine(getCtx(), getM_InOutLine_ID(), get_TrxName());
if (newRecord && parentline.getParent().isProcessed()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_InOut_ID"));
return false;
}
//Set DateMaterialPolicy
if(!newRecord && is_ValueChanged(COLUMNNAME_M_AttributeSetInstance_ID)){
//TODO Require testing for all scenario

View File

@ -286,8 +286,8 @@ public class MInventoryLine extends X_M_InventoryLine
*/
protected boolean beforeSave (boolean newRecord)
{
if (newRecord && getParent().isComplete()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_InventoryLine"));
if (newRecord && getParent().isProcessed()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_Inventory_ID"));
return false;
}

View File

@ -27,6 +27,7 @@ import java.util.logging.Level;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.Util;
@ -236,6 +237,11 @@ public class MInventoryLineMA extends X_M_InventoryLineMA
*/
protected boolean beforeSave (boolean newRecord)
{
MInventoryLine parentline = new MInventoryLine(getCtx(), getM_InventoryLine_ID(), get_TrxName());
if (newRecord && parentline.getParent().isProcessed()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_Inventory_ID"));
return false;
}
//Set DateMaterialPolicy
if(!newRecord && is_ValueChanged(COLUMNNAME_M_AttributeSetInstance_ID)){
I_M_InventoryLine line = getM_InventoryLine();

View File

@ -840,10 +840,10 @@ public class MInvoiceLine extends X_C_InvoiceLine
protected boolean beforeSave (boolean newRecord)
{
if (log.isLoggable(Level.FINE)) log.fine("New=" + newRecord);
boolean parentComplete = getParent().isComplete();
boolean parentComplete = getParent().isProcessed();
boolean isReversal = getParent().isReversal();
if (newRecord && parentComplete) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "C_InvoiceLine"));
log.saveError("ParentComplete", Msg.translate(getCtx(), "C_Invoice_ID"));
return false;
}
// Re-set invoice header (need to update m_IsSOTrx flag) - phib [ 1686773 ]

View File

@ -283,6 +283,13 @@ public class MJournal extends X_GL_Journal implements DocAction
*/
protected boolean beforeSave (boolean newRecord)
{
if (getGL_JournalBatch_ID() > 0) {
MJournalBatch parent = new MJournalBatch(getCtx(), getGL_JournalBatch_ID(), get_TrxName());
if (newRecord && parent.isProcessed()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "GL_JournalBatch_ID"));
return false;
}
}
// Imported Journals may not have date
if (getDateDoc() == null)
{

View File

@ -54,7 +54,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction
/**
*
*/
private static final long serialVersionUID = 5920767495976301905L;
private static final long serialVersionUID = 4447134860127309777L;
/**
* Create new Journal Batch by copying
@ -947,4 +947,17 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction
return true;
}
/**
* Document Status is Complete or Closed
* @return true if CO, CL or RE
*/
public boolean isComplete()
{
String ds = getDocStatus();
return DOCSTATUS_Completed.equals(ds)
|| DOCSTATUS_Closed.equals(ds)
|| DOCSTATUS_Reversed.equals(ds);
} // isComplete
} // MJournalBatch

View File

@ -285,8 +285,8 @@ public class MJournalLine extends X_GL_JournalLine
*/
protected boolean beforeSave (boolean newRecord)
{
if (newRecord && getParent().isComplete()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "GL_JournalLine"));
if (newRecord && getParent().isProcessed()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "GL_Journal_ID"));
return false;
}

View File

@ -51,7 +51,7 @@ public class MMovementConfirm extends X_M_MovementConfirm implements DocAction
/**
*
*/
private static final long serialVersionUID = -399427235334348654L;
private static final long serialVersionUID = -3617284116557414217L;
/**
* Create Confirmation or return existing one
@ -770,5 +770,16 @@ public class MMovementConfirm extends X_M_MovementConfirm implements DocAction
return 0;
} // getC_Currency_ID
/**
* Document Status is Complete or Closed
* @return true if CO, CL or RE
*/
public boolean isComplete()
{
String ds = getDocStatus();
return DOCSTATUS_Completed.equals(ds)
|| DOCSTATUS_Closed.equals(ds)
|| DOCSTATUS_Reversed.equals(ds);
} // isComplete
} // MMovementConfirm

View File

@ -167,8 +167,8 @@ public class MMovementLine extends X_M_MovementLine
@Override
protected boolean beforeSave (boolean newRecord)
{
if (newRecord && getParent().isComplete()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_MovementLine"));
if (newRecord && getParent().isProcessed()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_Movement_ID"));
return false;
}
if (getParent().pendingConfirmations()) {

View File

@ -21,6 +21,7 @@ import java.sql.ResultSet;
import java.util.Properties;
import org.compiere.util.Env;
import org.compiere.util.Msg;
/**
* Inventory Movement Confirmation Line
@ -148,6 +149,11 @@ public class MMovementLineConfirm extends X_M_MovementLineConfirm
*/
protected boolean beforeSave (boolean newRecord)
{
MMovementConfirm parent = new MMovementConfirm(getCtx(), getM_MovementConfirm_ID(), get_TrxName());
if (newRecord && parent.isProcessed()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_MovementConfirm_ID"));
return false;
}
// Calculate Difference = Target - Confirmed
BigDecimal difference = getTargetQty();
difference = difference.subtract(getConfirmedQty());

View File

@ -27,6 +27,7 @@ import java.util.logging.Level;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.Util;
@ -241,6 +242,11 @@ public class MMovementLineMA extends X_M_MovementLineMA
*/
protected boolean beforeSave (boolean newRecord)
{
MMovementLine parentline = new MMovementLine(getCtx(), getM_MovementLine_ID(), get_TrxName());
if (newRecord && parentline.getParent().isProcessed()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_Movement_ID"));
return false;
}
//Set DateMaterialPolicy
if(!newRecord && is_ValueChanged(COLUMNNAME_M_AttributeSetInstance_ID)){
I_M_MovementLine line = getM_MovementLine();

View File

@ -2026,12 +2026,12 @@ public class MOrder extends X_C_Order implements DocAction
MInvoice lastInvoice = invoices[0];
BigDecimal grandTotal = lastInvoice.getGrandTotal();
List<X_C_POSPayment> pps = new Query(this.getCtx(), X_C_POSPayment.Table_Name, "C_Order_ID=?", this.get_TrxName())
List<MPOSPayment> pps = new Query(this.getCtx(), MPOSPayment.Table_Name, "C_Order_ID=?", this.get_TrxName())
.setParameters(this.getC_Order_ID())
.setOnlyActiveRecords(true)
.list();
BigDecimal totalPOSPayments = Env.ZERO;
for (X_C_POSPayment pp : pps) {
for (MPOSPayment pp : pps) {
totalPOSPayments = totalPOSPayments.add(pp.getPayAmt());
}
if (totalPOSPayments.compareTo(grandTotal) != 0)
@ -2060,7 +2060,7 @@ public class MOrder extends X_C_Order implements DocAction
// Create a payment for each non-guarantee record
// associate the payment id and mark the record as processed
for (X_C_POSPayment pp : pps) {
for (MPOSPayment pp : pps) {
X_C_POSTenderType tt = new X_C_POSTenderType (getCtx(),pp.getC_POSTenderType_ID(), get_TrxName());
if (tt.isGuarantee())
continue;

View File

@ -775,8 +775,8 @@ public class MOrderLine extends X_C_OrderLine
*/
protected boolean beforeSave (boolean newRecord)
{
if (newRecord && getParent().isComplete()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "C_OrderLine"));
if (newRecord && getParent().isProcessed()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "C_Order_ID"));
return false;
}
// Get Defaults from Parent

View File

@ -0,0 +1,86 @@
/***********************************************************************
* This file is part of iDempiere ERP Open Source *
* http://www.idempiere.org *
* *
* Copyright (C) Contributors *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301, USA. *
* *
* Contributors: *
* - Carlos Ruiz - globalqss - bxservice *
**********************************************************************/
package org.compiere.model;
import java.sql.ResultSet;
import java.util.Properties;
import org.compiere.util.CLogger;
import org.compiere.util.Msg;
/**
*
* @author Carlos Ruiz - globalqss - bxservice
*
*/
public class MPOSPayment extends X_C_POSPayment
{
/**
*
*/
private static final long serialVersionUID = -4889347016616915128L;
/** Logger */
protected static CLogger s_log = CLogger.getCLogger (MPOSPayment.class);
/**************************************************************************
* Default Constructor
* @param ctx context
* @param C_POSPayment_ID order line to load
* @param trxName trx name
*/
public MPOSPayment (Properties ctx, int C_POSPayment_ID, String trxName)
{
super (ctx, C_POSPayment_ID, trxName);
} // MPOSPayment
/**
* Load Constructor
* @param ctx context
* @param rs result set record
* @param trxName transaction
*/
public MPOSPayment (Properties ctx, ResultSet rs, String trxName)
{
super(ctx, rs, trxName);
} // MPOSPayment
/**************************************************************************
* Before Save
* @param newRecord
* @return true if it can be saved
*/
protected boolean beforeSave (boolean newRecord)
{
MOrder parent = new MOrder(getCtx(), getC_Order_ID(), get_TrxName());
if (newRecord && parent.isProcessed()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "C_Order_ID"));
return false;
}
return true;
} // beforeSave
} // MPOSPayment

View File

@ -22,6 +22,7 @@ import java.util.Properties;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Msg;
/**
* Payment Selection Line Model
@ -143,6 +144,11 @@ public class MPaySelectionLine extends X_C_PaySelectionLine
*/
protected boolean beforeSave (boolean newRecord)
{
MPaySelection parent = new MPaySelection(getCtx(), getC_PaySelection_ID(), get_TrxName());
if (newRecord && parent.isProcessed()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "C_PaySelection_ID"));
return false;
}
setDifferenceAmt(getOpenAmt().subtract(getPayAmt()).subtract(getDiscountAmt()).subtract(getWriteOffAmt()));
return true;
} // beforeSave

View File

@ -663,7 +663,7 @@ public class MPayment extends X_C_Payment
*/
protected boolean beforeSave (boolean newRecord)
{
if (isComplete() &&
if (isProcessed() &&
! is_ValueChanged(COLUMNNAME_Processed) &&
( is_ValueChanged(COLUMNNAME_C_BankAccount_ID)
|| is_ValueChanged(COLUMNNAME_C_BPartner_ID)

View File

@ -26,7 +26,7 @@ public class MProduction extends X_M_Production implements DocAction {
/**
*
*/
private static final long serialVersionUID = -4650232602150964606L;
private static final long serialVersionUID = 6714776372370644208L;
/**
*
@ -907,4 +907,17 @@ public class MProduction extends X_M_Production implements DocAction {
}
return true;
}
/**
* Document Status is Complete or Closed
* @return true if CO, CL or RE
*/
public boolean isStatusComplete()
{
String ds = getDocStatus();
return DOCSTATUS_Completed.equals(ds)
|| DOCSTATUS_Closed.equals(ds)
|| DOCSTATUS_Reversed.equals(ds);
} // isStatusComplete
}

View File

@ -13,6 +13,7 @@ import java.util.logging.Level;
import org.adempiere.exceptions.AdempiereException;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.Util;
@ -354,6 +355,10 @@ public class MProductionLine extends X_M_ProductionLine {
if (getM_Production_ID() > 0)
{
if (newRecord && productionParent.isProcessed()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_Production_ID"));
return false;
}
if ( productionParent.getM_Product_ID() == getM_Product_ID() && productionParent.getProductionQty().signum() == getMovementQty().signum())
setIsEndProduct(true);
else
@ -362,6 +367,11 @@ public class MProductionLine extends X_M_ProductionLine {
else
{
I_M_ProductionPlan plan = getM_ProductionPlan();
MProduction prod = new MProduction(getCtx(), plan.getM_Production_ID(), get_TrxName());
if (newRecord && prod.isProcessed()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_Production_ID"));
return false;
}
if (plan.getM_Product_ID() == getM_Product_ID() && plan.getProductionQty().signum() == getMovementQty().signum())
setIsEndProduct(true);
else

View File

@ -8,13 +8,14 @@ import java.util.List;
import java.util.Properties;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.Util;
public class MProductionLineMA extends X_M_ProductionLineMA {
/**
*
*/
private static final long serialVersionUID = -3935841562652510880L;
private static final long serialVersionUID = -2633782218494352620L;
public MProductionLineMA(Properties ctx, int M_ProductionLineMA_ID,
String trxName) {
@ -95,5 +96,22 @@ public class MProductionLineMA extends X_M_ProductionLineMA {
return retValue;
} // get
@Override
protected boolean beforeSave(boolean newRecord)
{
MProductionLine parentLine = new MProductionLine(getCtx(), getM_ProductionLine_ID(), get_TrxName());
MProduction prodParent;
if (parentLine.getM_Production_ID() > 0) {
prodParent = new MProduction(getCtx(), parentLine.getM_Production_ID(), get_TrxName());
} else {
MProductionPlan plan = new MProductionPlan(getCtx(), parentLine.getM_ProductionPlan_ID(), get_TrxName());
prodParent = new MProduction(getCtx(), plan.getM_Production_ID(), get_TrxName());
}
if (newRecord && prodParent.isProcessed()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_Production_ID"));
return false;
}
return true;
}
}

View File

@ -14,17 +14,17 @@ import org.adempiere.exceptions.AdempiereException;
import org.compiere.util.AdempiereUserError;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Msg;
/**
* @author hengsin
*
*/
public class MProductionPlan extends X_M_ProductionPlan {
/**
* generated serial id
*
*/
private static final long serialVersionUID = -8189507724698695756L;
private static final long serialVersionUID = 1830027775110768396L;
/**
* @param ctx
@ -303,4 +303,16 @@ public class MProductionPlan extends X_M_ProductionPlan {
deleteLines(get_TrxName());
return true;
}
@Override
protected boolean beforeSave(boolean newRecord)
{
MProduction parent = new MProduction(getCtx(), getM_Production_ID(), get_TrxName());
if (newRecord && parent.isProcessed()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_Production_ID"));
return false;
}
return true;
}
}

View File

@ -267,9 +267,9 @@ public class MRMALine extends X_M_RMALine
@Override
protected boolean beforeSave(boolean newRecord)
{
if (newRecord && getParent().isComplete())
if (newRecord && getParent().isProcessed())
{
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_RMA"));
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_RMA_ID"));
return false;
}
if (getM_InOutLine_ID() == 0 && getC_Charge_ID() == 0 && getM_Product_ID() == 0)

View File

@ -259,8 +259,8 @@ public class MRequisitionLine extends X_M_RequisitionLine
*/
protected boolean beforeSave (boolean newRecord)
{
if (newRecord && getParent().isComplete()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_RequisitionLine"));
if (newRecord && getParent().isProcessed()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_Requisition_ID"));
return false;
}
if (getLine() == 0)

View File

@ -190,8 +190,8 @@ public class MTimeExpenseLine extends X_S_TimeExpenseLine
*/
protected boolean beforeSave (boolean newRecord)
{
if (newRecord && getParent().isComplete()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "S_TimeExpenseLine"));
if (newRecord && getParent().isProcessed()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "S_TimeExpense_ID"));
return false;
}
// Calculate Converted Amount

View File

@ -515,8 +515,8 @@ public class MDDOrderLine extends X_DD_OrderLine
*/
protected boolean beforeSave (boolean newRecord)
{
if (newRecord && getParent().isComplete()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "DD_OrderLine"));
if (newRecord && getParent().isProcessed()) {
log.saveError("ParentComplete", Msg.translate(getCtx(), "DD_Order_ID"));
return false;
}
// Get Defaults from Parent