IDEMPIERE-4709 Print Format Item: implement script column (expression) (#663)
Peer review and tests
This commit is contained in:
parent
f74e6c7824
commit
713aa09a46
|
@ -21,10 +21,6 @@ INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,I
|
||||||
UPDATE AD_Field SET DisplayLogic='@PrintFormatType@=''S''', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-02-20 13:51:58','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206598
|
UPDATE AD_Field SET DisplayLogic='@PrintFormatType@=''S''', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-02-20 13:51:58','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206598
|
||||||
;
|
;
|
||||||
|
|
||||||
-- Feb 20, 2021, 1:52:53 PM BRT
|
|
||||||
UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, ReadOnlyLogic='@PrintFormatType@=''S''', IsToolbarButton=NULL,Updated=TO_DATE('2021-02-20 13:52:53','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5668
|
|
||||||
;
|
|
||||||
|
|
||||||
-- Feb 20, 2021, 1:58:50 PM BRT
|
-- Feb 20, 2021, 1:58:50 PM BRT
|
||||||
UPDATE AD_Field SET DisplayLogic='@PrintFormatType@=F | @PrintFormatType@=S', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-02-20 13:58:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=56373
|
UPDATE AD_Field SET DisplayLogic='@PrintFormatType@=F | @PrintFormatType@=S', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-02-20 13:58:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=56373
|
||||||
;
|
;
|
||||||
|
@ -37,8 +33,9 @@ UPDATE AD_Field SET DisplayLogic='@PrintFormatType@=S', AD_Reference_Value_ID=NU
|
||||||
UPDATE AD_Field SET AD_FieldGroup_ID=200015, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-02-20 14:00:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206598
|
UPDATE AD_Field SET AD_FieldGroup_ID=200015, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2021-02-20 14:00:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206598
|
||||||
;
|
;
|
||||||
|
|
||||||
|
-- Apr 22, 2021, 8:05:02 PM CEST
|
||||||
|
UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, ReadOnlyLogic='@#ShowAdvanced@=N', IsToolbarButton=NULL,Updated=TO_DATE('2021-04-22 20:05:02','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206598
|
||||||
|
;
|
||||||
|
|
||||||
SELECT register_migration_script('202102201441_IDEMPIERE-4709.sql') FROM dual
|
SELECT register_migration_script('202102201441_IDEMPIERE-4709.sql') FROM dual
|
||||||
;
|
;
|
|
@ -18,10 +18,6 @@ INSERT INTO AD_Field (AD_Field_ID,Name,Description,Help,AD_Tab_ID,AD_Column_ID,I
|
||||||
UPDATE AD_Field SET DisplayLogic='@PrintFormatType@=''S''', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-02-20 13:51:58','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206598
|
UPDATE AD_Field SET DisplayLogic='@PrintFormatType@=''S''', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-02-20 13:51:58','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206598
|
||||||
;
|
;
|
||||||
|
|
||||||
-- Feb 20, 2021, 1:52:53 PM BRT
|
|
||||||
UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, ReadOnlyLogic='@PrintFormatType@=''S''', IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-02-20 13:52:53','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5668
|
|
||||||
;
|
|
||||||
|
|
||||||
-- Feb 20, 2021, 1:58:50 PM BRT
|
-- Feb 20, 2021, 1:58:50 PM BRT
|
||||||
UPDATE AD_Field SET DisplayLogic='@PrintFormatType@=F | @PrintFormatType@=S', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-02-20 13:58:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=56373
|
UPDATE AD_Field SET DisplayLogic='@PrintFormatType@=F | @PrintFormatType@=S', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-02-20 13:58:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=56373
|
||||||
;
|
;
|
||||||
|
@ -34,7 +30,9 @@ UPDATE AD_Field SET DisplayLogic='@PrintFormatType@=S', AD_Reference_Value_ID=NU
|
||||||
UPDATE AD_Field SET AD_FieldGroup_ID=200015, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-02-20 14:00:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206598
|
UPDATE AD_Field SET AD_FieldGroup_ID=200015, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-02-20 14:00:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206598
|
||||||
;
|
;
|
||||||
|
|
||||||
|
-- Apr 22, 2021, 8:05:02 PM CEST
|
||||||
|
UPDATE AD_Field SET AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, ReadOnlyLogic='@#ShowAdvanced@=N', IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2021-04-22 20:05:02','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206598
|
||||||
|
;
|
||||||
|
|
||||||
SELECT register_migration_script('202102201441_IDEMPIERE-4709.sql') FROM dual
|
SELECT register_migration_script('202102201441_IDEMPIERE-4709.sql') FROM dual
|
||||||
;
|
;
|
|
@ -94,17 +94,6 @@
|
||||||
tableName="AD_InfoColumn">
|
tableName="AD_InfoColumn">
|
||||||
</callout>
|
</callout>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
|
||||||
id="org.adempiere.model.CalloutPrintFormatType.printformattype"
|
|
||||||
point="org.adempiere.base.IColumnCallout">
|
|
||||||
<callout
|
|
||||||
class="org.adempiere.model.CalloutPrintFormatType"
|
|
||||||
columnName="PrintFormatType"
|
|
||||||
priority="0"
|
|
||||||
tableName="AD_PrintFormatItem">
|
|
||||||
</callout>
|
|
||||||
</extension>
|
|
||||||
|
|
||||||
<extension
|
<extension
|
||||||
id="org.compiere.model.StandardTaxProvider"
|
id="org.compiere.model.StandardTaxProvider"
|
||||||
name="Standard Tax Provider"
|
name="Standard Tax Provider"
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
package org.adempiere.model;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.adempiere.base.IColumnCallout;
|
|
||||||
import org.compiere.model.GridField;
|
|
||||||
import org.compiere.model.GridTab;
|
|
||||||
import org.compiere.model.X_AD_PrintFormatItem;
|
|
||||||
import org.compiere.util.DB;
|
|
||||||
|
|
||||||
public class CalloutPrintFormatType implements IColumnCallout {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String start(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value, Object oldValue) {
|
|
||||||
|
|
||||||
String printFormatType = (String)value;
|
|
||||||
|
|
||||||
if(!X_AD_PrintFormatItem.PRINTFORMATTYPE_Script.equals(printFormatType))
|
|
||||||
return null;
|
|
||||||
|
|
||||||
int AD_PrintFormat_ID = (Integer) mTab.getValue("AD_PrintFormat_ID");
|
|
||||||
|
|
||||||
int count = DB.getSQLValue(null, "SELECT count(*) FROM AD_PrintFormatItem WHERE PrintFormatType = 'S' AND AD_PrintFormat_ID = ?",AD_PrintFormat_ID);
|
|
||||||
mTab.setValue("Name", "SCRIPTCOLUMN"+count );
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -280,7 +280,7 @@ public class DataEngine
|
||||||
.append("c.ColumnSQL, COALESCE(pfi.FormatPattern, c.FormatPattern) ") // 24, 25
|
.append("c.ColumnSQL, COALESCE(pfi.FormatPattern, c.FormatPattern) ") // 24, 25
|
||||||
//BEGIN http://jira.idempiere.com/browse/IDEMPIERE-153
|
//BEGIN http://jira.idempiere.com/browse/IDEMPIERE-153
|
||||||
/** START DEVCOFFEE: script column **/
|
/** START DEVCOFFEE: script column **/
|
||||||
.append(" , pfi.isDesc, pfi.Script, pfi.Name ") //26
|
.append(" , pfi.isDesc, pfi.Script, pfi.Name ") // 26..28
|
||||||
//END
|
//END
|
||||||
.append("FROM AD_PrintFormat pf")
|
.append("FROM AD_PrintFormat pf")
|
||||||
.append(" INNER JOIN AD_PrintFormatItem pfi ON (pf.AD_PrintFormat_ID=pfi.AD_PrintFormat_ID)")
|
.append(" INNER JOIN AD_PrintFormatItem pfi ON (pf.AD_PrintFormat_ID=pfi.AD_PrintFormat_ID)")
|
||||||
|
@ -410,6 +410,7 @@ public class DataEngine
|
||||||
if (script.startsWith("@SQL="))
|
if (script.startsWith("@SQL="))
|
||||||
{
|
{
|
||||||
script = "(" + script.replace("@SQL=", "") + ")";
|
script = "(" + script.replace("@SQL=", "") + ")";
|
||||||
|
script = Env.parseContext(Env.getCtx(), 0, script, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
script = "'@SCRIPT" + script + "'";
|
script = "'@SCRIPT" + script + "'";
|
||||||
|
@ -1315,12 +1316,6 @@ public class DataEngine
|
||||||
|
|
||||||
token = inStr.substring(0, j);
|
token = inStr.substring(0, j);
|
||||||
|
|
||||||
//format string
|
|
||||||
int f = token.indexOf('<');
|
|
||||||
if (f > 0 && token.endsWith(">")) {
|
|
||||||
token = token.substring(0, f);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (token.startsWith("ACCUMULATE/")) {
|
if (token.startsWith("ACCUMULATE/")) {
|
||||||
|
|
||||||
token = token.replace("ACCUMULATE/", "");
|
token = token.replace("ACCUMULATE/", "");
|
||||||
|
|
|
@ -737,8 +737,9 @@ public class MPrintFormatItem extends X_AD_PrintFormatItem implements ImmutableP
|
||||||
setScript(null);
|
setScript(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Util.isEmpty(getScript()) && is_ValueChanged(MPrintFormatItem.COLUMNNAME_Script)
|
if( !Util.isEmpty(getScript())
|
||||||
&& getScript().contains("@SQL") && !MRole.getDefault().isAccessAdvanced()) {
|
&& is_ValueChanged(MPrintFormatItem.COLUMNNAME_Script)
|
||||||
|
&& !MRole.getDefault().isAccessAdvanced()) {
|
||||||
log.saveError("Error", Msg.getMsg(getCtx(), "ActionNotAllowedHere"));
|
log.saveError("Error", Msg.getMsg(getCtx(), "ActionNotAllowedHere"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue