IDEMPIERE-1887 can make inconsistent data from physical inventory window

This commit is contained in:
Carlos Ruiz 2019-02-14 15:51:50 +01:00
parent c5b7b7dfea
commit 8a2a08b61e
3 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,11 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-1887 can make inconsistent data from physical inventory window
-- Feb 14, 2019, 3:40:50 PM CET
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('E','Warehouse cannot be changed because there are lines.',0,0,'Y',TO_DATE('2019-02-14 15:40:49','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2019-02-14 15:40:49','YYYY-MM-DD HH24:MI:SS'),100,200487,'CannotChangeWarehouse','D','2a9c7a1b-35b2-464c-a2ba-0aa60be3d81d')
;
SELECT register_migration_script('201902141541_IDEMPIERE-1887.sql') FROM dual
;

View File

@ -0,0 +1,8 @@
-- IDEMPIERE-1887 can make inconsistent data from physical inventory window
-- Feb 14, 2019, 3:40:50 PM CET
INSERT INTO AD_Message (MsgType,MsgText,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('E','Warehouse cannot be changed because there are lines.',0,0,'Y',TO_TIMESTAMP('2019-02-14 15:40:49','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2019-02-14 15:40:49','YYYY-MM-DD HH24:MI:SS'),100,200487,'CannotChangeWarehouse','D','2a9c7a1b-35b2-464c-a2ba-0aa60be3d81d')
;
SELECT register_migration_script('201902141541_IDEMPIERE-1887.sql') FROM dual
;

View File

@ -255,6 +255,14 @@ public class MInventory extends X_M_Inventory implements DocAction
log.saveError("FillMandatory", Msg.getElement(getCtx(), COLUMNNAME_C_DocType_ID));
return false;
}
// IDEMPIERE-1887 can make inconsistent data from physical inventory window
if (!newRecord && is_ValueChanged(COLUMNNAME_M_Warehouse_ID)) {
int cnt = DB.getSQLValueEx(get_TrxName(), "SELECT COUNT(*) FROM M_InventoryLine WHERE M_Inventory_ID=?", getM_Inventory_ID());
if (cnt > 0) {
log.saveError("Error", Msg.getMsg(getCtx(), "CannotChangeWarehouse"));
return false;
}
}
return true;
} // beforeSave