IDEMPIERE-1437 Do not allow changing Table in Tab when there are Fields (#1927)

This commit is contained in:
Carlos Ruiz 2023-07-08 05:17:37 +02:00 committed by GitHub
parent 71a49baf00
commit 34a33ba06f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,10 @@
-- IDEMPIERE-1437
SELECT register_migration_script('202307061451_IDEMPIERE-1437.sql') FROM dual;
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Jul 6, 2023, 2:51:25 PM CEST
UPDATE AD_Field SET ReadOnlyLogic='@SQL=SELECT 1 FROM AD_Field WHERE AD_Tab_ID=@AD_Tab_ID@',Updated=TO_TIMESTAMP('2023-07-06 14:51:25','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=131
;

View File

@ -0,0 +1,7 @@
-- IDEMPIERE-1437
SELECT register_migration_script('202307061451_IDEMPIERE-1437.sql') FROM dual;
-- Jul 6, 2023, 2:51:25 PM CEST
UPDATE AD_Field SET ReadOnlyLogic='@SQL=SELECT 1 FROM AD_Field WHERE AD_Tab_ID=@AD_Tab_ID@',Updated=TO_TIMESTAMP('2023-07-06 14:51:25','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=131
;

View File

@ -232,6 +232,11 @@ public class MTab extends X_AD_Tab implements ImmutablePOSupport
*/
protected boolean beforeSave (boolean newRecord)
{
if (! newRecord && is_ValueChanged(COLUMNNAME_AD_Table_ID) && getFields(false, get_TrxName()).length > 0) {
log.saveError("Error", "Cannot change table if there are related fields");
return false;
}
if (isReadOnly() && isInsertRecord())
setIsInsertRecord(false);
if (is_new() || is_ValueChanged(COLUMNNAME_AD_TabType))