IDEMPIERE-678 Cannot copy a print format twice
This commit is contained in:
parent
3cbcf56110
commit
0e09ac40e9
|
@ -61,7 +61,7 @@ public class MPrintFormat extends X_AD_PrintFormat
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -8307496567084341384L;
|
private static final long serialVersionUID = -1378114118642378625L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public Constructor.
|
* Public Constructor.
|
||||||
|
@ -803,17 +803,27 @@ public class MPrintFormat extends X_AD_PrintFormat
|
||||||
return pf;
|
return pf;
|
||||||
} // createFromReportView
|
} // createFromReportView
|
||||||
|
|
||||||
private static void setUniqueName(int AD_Client_ID, MPrintFormat pf, String basename) {
|
public static void setUniqueName(int AD_Client_ID, MPrintFormat pf, String basename) {
|
||||||
String name = basename;
|
String name = basename;
|
||||||
pf.setName(name);
|
pf.setName(name);
|
||||||
|
boolean dateAsSuffix = true;
|
||||||
boolean sleep = false;
|
boolean sleep = false;
|
||||||
while (exists(AD_Client_ID, name)) {
|
while (exists(AD_Client_ID, pf.getName())) {
|
||||||
if (sleep)
|
if (sleep)
|
||||||
Env.sleep(1); // wait 1 sec to get next second in datetime
|
Env.sleep(1); // wait 1 sec to get next second in datetime
|
||||||
else
|
else
|
||||||
sleep = true;
|
sleep = true;
|
||||||
|
if (dateAsSuffix) {
|
||||||
name = basename + "_" + getDateTime();
|
name = basename + "_" + getDateTime();
|
||||||
|
} else {
|
||||||
|
name = getDateTime() + "_" + basename;
|
||||||
|
}
|
||||||
pf.setName(name);
|
pf.setName(name);
|
||||||
|
if (sleep && !name.equals(pf.getName())) {
|
||||||
|
// there has been already one iteration and the name is being truncated
|
||||||
|
// change method to put date as prefix
|
||||||
|
dateAsSuffix = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1029,8 +1039,8 @@ public class MPrintFormat extends X_AD_PrintFormat
|
||||||
// Set Name - Remove TEMPLATE - add copy
|
// Set Name - Remove TEMPLATE - add copy
|
||||||
to.setName(Util.replace(to.getName(), "TEMPLATE", String.valueOf(to_Client_ID)));
|
to.setName(Util.replace(to.getName(), "TEMPLATE", String.valueOf(to_Client_ID)));
|
||||||
to.setName(to.getName()
|
to.setName(to.getName()
|
||||||
+ " - " + Util.cleanAmp(Msg.getMsg(ctx, "Copy"))
|
+ " - " + Util.cleanAmp(Msg.getMsg(ctx, "Copy")));
|
||||||
+ " " + getDateTime()); // unique name
|
setUniqueName(to.getAD_Client_ID(), to, to.getName());
|
||||||
//
|
//
|
||||||
to.saveEx();
|
to.saveEx();
|
||||||
|
|
||||||
|
|
|
@ -1473,8 +1473,10 @@ public class FinReport extends SvrProcess
|
||||||
pf = MPrintFormat.get (getCtx(), AD_PrintFormat_ID, false); // use Cache
|
pf = MPrintFormat.get (getCtx(), AD_PrintFormat_ID, false); // use Cache
|
||||||
|
|
||||||
// Print Format Sync
|
// Print Format Sync
|
||||||
if (!m_report.getName().equals(pf.getName()))
|
if (!m_report.getName().equals(pf.getName())) {
|
||||||
pf.setName(m_report.getName());
|
pf.setName(m_report.getName());
|
||||||
|
MPrintFormat.setUniqueName(pf.getAD_Client_ID(), pf, pf.getName());
|
||||||
|
}
|
||||||
if (m_report.getDescription() == null)
|
if (m_report.getDescription() == null)
|
||||||
{
|
{
|
||||||
if (pf.getDescription () != null)
|
if (pf.getDescription () != null)
|
||||||
|
|
Loading…
Reference in New Issue