hg merge release-5.1 (merge release5.1 into default)

This commit is contained in:
Carlos Ruiz 2018-04-08 21:06:13 +02:00
commit da53148c79
17 changed files with 236 additions and 37 deletions

View File

@ -0,0 +1,15 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-3664
-- Mar 22, 2018 10:16:54 AM BRT
INSERT INTO AD_SysConfig (AD_SysConfig_ID,AD_Client_ID,AD_Org_ID,Created,Updated,CreatedBy,UpdatedBy,IsActive,Name,Value,Description,EntityType,ConfigurationLevel,AD_SysConfig_UU) VALUES (200116,0,0,TO_DATE('2018-03-22 10:16:53','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2018-03-22 10:16:53','YYYY-MM-DD HH24:MI:SS'),100,100,'Y','AUTO_ASSIGN_ROLE_TO_CREATOR_USER','N','Defines if a role is assigned to the creator user when creating a new role ','D','S','dc4be8d1-a164-4e6d-8e02-be6c498d1669')
;
-- Mar 22, 2018 10:17:03 AM BRT
UPDATE AD_SysConfig SET ConfigurationLevel='C',Updated=TO_DATE('2018-03-22 10:17:03','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_SysConfig_ID=200116
;
SELECT register_migration_script('201803221017_IDEMPIERE-3664.sql') FROM dual
;

View File

@ -0,0 +1,12 @@
-- IDEMPIERE-3664
-- Mar 22, 2018 10:16:54 AM BRT
INSERT INTO AD_SysConfig (AD_SysConfig_ID,AD_Client_ID,AD_Org_ID,Created,Updated,CreatedBy,UpdatedBy,IsActive,Name,Value,Description,EntityType,ConfigurationLevel,AD_SysConfig_UU) VALUES (200116,0,0,TO_TIMESTAMP('2018-03-22 10:16:53','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2018-03-22 10:16:53','YYYY-MM-DD HH24:MI:SS'),100,100,'Y','AUTO_ASSIGN_ROLE_TO_CREATOR_USER','N','Defines if a role is assigned to the creator user when creating a new role ','D','S','dc4be8d1-a164-4e6d-8e02-be6c498d1669')
;
-- Mar 22, 2018 10:17:03 AM BRT
UPDATE AD_SysConfig SET ConfigurationLevel='C',Updated=TO_TIMESTAMP('2018-03-22 10:17:03','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_SysConfig_ID=200116
;
SELECT register_migration_script('201803221017_IDEMPIERE-3664.sql') FROM dual
;

View File

@ -445,10 +445,13 @@ public class Doc_MatchPO extends Doc
&& mPO[i].getM_MatchPO_ID() != mMatchPO.getM_MatchPO_ID())
{
BigDecimal qty = (isReturnTrx ? mPO[i].getQty().negate() : mPO[i].getQty());
if (mPO[i].getM_InOutLine_ID() > 0)
{
tQty = tQty.add(qty);
tAmt = tAmt.add(poCost.multiply(qty));
}
}
}
poCost = poCost.multiply(getQty()); // Delivered so far
tAmt = tAmt.add(isReturnTrx ? poCost.negate() : poCost);

View File

@ -734,7 +734,7 @@ public class Doc_Order extends Doc
* @param multiplier 1 for accrual
* @return Fact
*/
protected static Fact getCommitmentSalesRelease(MAcctSchema as, Doc doc,
public static Fact getCommitmentSalesRelease(MAcctSchema as, Doc doc,
BigDecimal Qty, int M_InOutLine_ID, BigDecimal multiplier)
{
Fact fact = new Fact(doc, as, Fact.POST_Commitment);

View File

@ -515,8 +515,87 @@ public class MMatchPO extends X_M_MatchPO
{
retValue = new MMatchPO (sLine, dateTrx, qty);
retValue.setC_OrderLine_ID(C_OrderLine_ID);
if (iLine != null)
MMatchPO otherMatchPO = null;
if (iLine == null) {
MMatchPO[] matchPOs = MMatchPO.getOrderLine(retValue.getCtx(), sLine.getC_OrderLine_ID(), retValue.get_TrxName());
for (MMatchPO matchPO : matchPOs)
{
if (matchPO.getC_InvoiceLine_ID() > 0 && matchPO.getM_InOutLine_ID() == 0)
{
//m_matchinv not created yet
int cnt = DB.getSQLValueEx(sLine.get_TrxName(), "SELECT Count(*) FROM M_MatchInv WHERE M_InOutLine_ID="+sLine.getM_InOutLine_ID()
+" AND C_InvoiceLine_ID="+ matchPO.getC_InvoiceLine_ID());
if (cnt <= 0) {
if (!matchPO.isPosted() && matchPO.getQty().compareTo(retValue.getQty()) >=0 ) // greater than or equal quantity
{
otherMatchPO = matchPO;
iLine = new MInvoiceLine(retValue.getCtx(), matchPO.getC_InvoiceLine_ID(), retValue.get_TrxName());
matchPO.setQty(matchPO.getQty().subtract(retValue.getQty()));
if (matchPO.getQty().signum() == 0 )
matchPO.deleteEx(true);
else
matchPO.saveEx();
break;
}
}
}
}
}
if (iLine != null) {
if (otherMatchPO == null)
retValue.setC_InvoiceLine_ID(iLine);
//auto create matchinv
if (otherMatchPO != null)
{
Savepoint savepoint = null;
Trx trx = null;
try
{
trx = trxName != null ? Trx.get(trxName, false) : null;
savepoint = trx != null ? trx.getConnection().setSavepoint() : null;
MMatchInv matchInv = new MMatchInv(retValue.getCtx(), 0, retValue.get_TrxName());
matchInv.setC_InvoiceLine_ID(otherMatchPO.getC_InvoiceLine_ID());
matchInv.setM_Product_ID(retValue.getM_Product_ID());
matchInv.setM_InOutLine_ID(retValue.getM_InOutLine_ID());
matchInv.setAD_Client_ID(retValue.getAD_Client_ID());
matchInv.setAD_Org_ID(retValue.getAD_Org_ID());
matchInv.setM_AttributeSetInstance_ID(retValue.getM_AttributeSetInstance_ID());
matchInv.setQty(retValue.getQty());
matchInv.setDateTrx(dateTrx);
matchInv.setProcessed(true);
if (!matchInv.save())
{
if (savepoint != null)
{
trx.getConnection().rollback(savepoint);
savepoint = null;
}
else
{
matchInv.delete(true);
}
String msg = "Failed to auto match invoice.";
ValueNamePair error = CLogger.retrieveError();
if (error != null)
{
msg = msg + " " + error.getName();
}
s_log.severe(msg);
}
retValue.setMatchInvCreated(matchInv);
} catch (Exception e) {
s_log.log(Level.SEVERE, "Failed to auto match Invoice.", e);
} finally {
if (savepoint != null)
{
try {
trx.getConnection().releaseSavepoint(savepoint);
} catch (Exception e) {}
}
}
}
}
if (!retValue.save())
{
String msg = "Failed to update match po.";
@ -972,6 +1051,11 @@ public class MMatchPO extends X_M_MatchPO
orderLine.setQtyInvoiced(orderLine.getQtyInvoiced().subtract(getQty()));
orderLine.setDateInvoiced(getDateTrx()); // overwrite=last
}
else if (!newRecord && getC_InvoiceLine_ID() > 0 && is_ValueChanged(COLUMNNAME_Qty))
{
BigDecimal oldQty = (BigDecimal)(get_ValueOld(COLUMNNAME_Qty));
orderLine.setQtyInvoiced(orderLine.getQtyInvoiced().subtract(oldQty.subtract(getQty())));
}
// Update Order ASI if full match
if (orderLine.getM_AttributeSetInstance_ID() == 0
@ -1183,6 +1267,36 @@ public class MMatchPO extends X_M_MatchPO
this.setDescription("(" + reversal.getDocumentNo() + "<-)");
this.setReversal_ID(reversal.getM_MatchPO_ID());
this.saveEx();
// reversal of mr if have both shipment and invoice line
if ( reversal.getM_InOutLine_ID() > 0 && reversal.getC_InvoiceLine_ID() > 0)
{
MMatchPO[] matchPOs = MMatchPO.getOrderLine(reversal.getCtx(), reversal.getC_OrderLine_ID(), reversal.get_TrxName());
BigDecimal matchQty = getQty();
for (MMatchPO matchPO : matchPOs)
{
if (matchPO.getReversal_ID() == 0 && !matchPO.isPosted()
&& matchPO.getC_InvoiceLine_ID() == reversal.getC_InvoiceLine_ID()
&& matchPO.getM_InOutLine_ID() == 0 )
{
matchPO.setQty(matchPO.getQty().add(matchQty));
matchPO.saveEx();
matchQty = BigDecimal.ZERO;
break;
}
}
if (matchQty.signum() != 0)
{
MMatchPO matchPO = new MMatchPO (getCtx(), 0, get_TrxName());
PO.copyValues(this, matchPO);
matchPO.setC_InvoiceLine_ID(getC_InvoiceLine_ID());
matchPO.setM_InOutLine_ID(0);
matchPO.setDescription(null);
matchPO.setPosted (false);
matchPO.saveEx();
}
}
return true;
}
return false;

View File

@ -371,7 +371,7 @@ public final class MRole extends X_AD_Role
MUserRoles su = new MUserRoles(getCtx(), SUPERUSER_USER_ID, getAD_Role_ID(), get_TrxName());
su.saveEx();
// Add Role to User
if (getCreatedBy() != SUPERUSER_USER_ID)
if (getCreatedBy() != SUPERUSER_USER_ID && MSysConfig.getBooleanValue(MSysConfig.AUTO_ASSIGN_ROLE_TO_CREATOR_USER, false, getAD_Client_ID()))
{
MUserRoles ur = new MUserRoles(getCtx(), getCreatedBy(), getAD_Role_ID(), get_TrxName());
ur.saveEx();

View File

@ -42,7 +42,7 @@ public class MSysConfig extends X_AD_SysConfig
/**
*
*/
private static final long serialVersionUID = 2617379167881737860L;
private static final long serialVersionUID = -2698648078997788547L;
public static final String ADDRESS_VALIDATION = "ADDRESS_VALIDATION";
public static final String ALERT_SEND_ATTACHMENT_AS_XLS = "ALERT_SEND_ATTACHMENT_AS_XLS";
@ -61,6 +61,7 @@ public class MSysConfig extends X_AD_SysConfig
public static final String APPLICATION_OS_INFO_SHOWN = "APPLICATION_OS_INFO_SHOWN";
public static final String APPLICATION_URL = "APPLICATION_URL";
public static final String ATTACH_EMBEDDED_2PACK = "ATTACH_EMBEDDED_2PACK";
public static final String AUTO_ASSIGN_ROLE_TO_CREATOR_USER = "AUTO_ASSIGN_ROLE_TO_CREATOR_USER";
public static final String AUTOMATIC_PACKIN_FOLDERS = "AUTOMATIC_PACKIN_FOLDERS";
public static final String AUTOMATIC_PACKIN_INITIAL_DELAY = "AUTOMATIC_PACKIN_INITIAL_DELAY";
public static final String AUTOMATIC_PACKIN_PROCESSING = "AUTOMATIC_PACKIN_PROCESSING";

View File

@ -2846,6 +2846,7 @@ public abstract class PO
if (DisplayType.isLOB(dt))
{
lobAdd (value, i, dt);
if (!p_info.isColumnMandatory(i))
continue;
}
@ -2885,7 +2886,16 @@ public abstract class PO
else if (c == String.class)
sqlValues.append (encrypt(i,DB.TO_STRING ((String)value)));
else if (DisplayType.isLOB(dt))
sqlValues.append("null"); // no db dependent stuff here
{
if (p_info.isColumnMandatory(i))
{
sqlValues.append("''"); // no db dependent stuff here -- at this point value is known to be not null
}
else
{
sqlValues.append("null");
}
}
else
sqlValues.append (saveNewSpecial (value, i));
}
@ -2909,9 +2919,19 @@ public abstract class PO
sqlValues.append("?");
if (DisplayType.isLOB(dt))
{
if (p_info.isColumnMandatory(i))
{
if (dt == DisplayType.Binary)
params.add(new byte[] {0}); // -- at this point value is known to be not null
else
params.add(""); // -- at this point value is known to be not null
}
else
{
params.add(null);
}
}
else if (value == null || value.equals (Null.NULL))
{
params.add(null);

View File

@ -42,6 +42,10 @@ public class PipoDictionaryService implements IDictionaryService {
logger.info("No PackIn Model found");
return;
}
if (! packageFile.canRead()) {
logger.severe("Cannot read file " + packageFile.getName());
return;
}
String symbolicName = "org.adempiere.pipo";
if (context != null)
symbolicName = context.getBundle().getSymbolicName();

View File

@ -299,7 +299,7 @@ public class PackInApplicationActivator extends AbstractActivator {
for (String filePath : filePaths) {
File toProcess = new File(filePath.trim());
if (!toProcess.exists()) {
logger.log(Level.SEVERE, filePath + " does not exist");
addLog(Level.SEVERE, filePath + " does not exist");
continue;
}
@ -322,14 +322,14 @@ public class PackInApplicationActivator extends AbstractActivator {
}
private void processFilePath(File toProcess) {
if (toProcess.isFile()) {
if (toProcess.isFile() && toProcess.canRead()) {
if (toProcess.getName().toLowerCase().endsWith(".zip"))
filesToProcess.add(toProcess);
else {
logger.log(Level.SEVERE, toProcess.getName() + " is not a valid .zip file");
return;
}
} else if (toProcess.isDirectory()) {
} else if (toProcess.isDirectory() && toProcess.canRead()) {
FileFilter filter = new FileFilter() {
public boolean accept(File file) {
if (file.getName().toUpperCase().endsWith(".ZIP") || file.isDirectory())
@ -344,17 +344,22 @@ public class PackInApplicationActivator extends AbstractActivator {
logger.info("*** Creating list from folder " + toProcess.toString());
found = true;
}
if (fileToProcess.isDirectory())
if (fileToProcess.isDirectory()) {
processFilePath(fileToProcess);
else
} else {
if (fileToProcess.canRead()) {
filesToProcess.add(fileToProcess);
} else {
addLog(Level.SEVERE, fileToProcess.getName() + " not readable");
}
}
}
if (!found) {
logger.log(Level.FINE, toProcess.getName() + " does not have .zip files or subfolders");
return;
}
} else {
logger.log(Level.SEVERE, toProcess.getName() + " not a file or folder");
addLog(Level.SEVERE, toProcess.getName() + " not a file or folder or not readable");
}
}

View File

@ -38,7 +38,7 @@ url.file.jp.lib=http://downloads.sourceforge.net/project/idempiere/binary.file/j
url.jp.p2=http://downloads.sourceforge.net/project/idempiere/binary.file/jarfile/jp-p2/jp-6.3.1
url.alpn.boot=http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/8.1.11.v20170118/alpn-boot-8.1.11.v20170118.jar
url.alpn.boot=http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/8.1.12.v20180117/alpn-boot-8.1.12.v20180117.jar
extend.bundle.folder.1
extend.bundle.folder.2

View File

@ -1,4 +1,4 @@
osgi.framework=file\:../plugins/org.eclipse.osgi_3.12.50.v20170928-1321.jar
osgi.framework=file\:../plugins/org.eclipse.osgi_3.12.100.v20180210-1608.jar
osgi.install.area=setup
osgi.bundles=org.eclipse.equinox.ds@1:start,\
org.eclipse.equinox.util,\

View File

@ -117,13 +117,21 @@ public abstract class AdempiereServer implements Runnable
}
m_sleepMS = 0;
m_nextWork = 0;
Timestamp lastRun = new Timestamp(System.currentTimeMillis());
m_nextWork = MSchedule.getNextRunMS(lastRun.getTime(),
Timestamp dateNextRun = getDateNextRun(true);
Timestamp now = new Timestamp(System.currentTimeMillis());
if (dateNextRun != null)
{
m_nextWork = dateNextRun.getTime();
}
else
{
m_nextWork = MSchedule.getNextRunMS(now.getTime(),
p_model.getScheduleType(), p_model.getFrequencyType(),
p_model.getFrequency(), p_model.getCronPattern());
}
m_sleepMS = m_nextWork - lastRun.getTime();
if (m_nextWork > now.getTime())
m_sleepMS = m_nextWork - now.getTime();
if (log.isLoggable(Level.INFO)) log.info(" Next run: " + new Timestamp(m_nextWork) + " sleep " + m_sleepMS);
//
p_model.setDateNextRun(new Timestamp(m_nextWork));

View File

@ -176,6 +176,7 @@ public class AdempiereServerMgr implements ServiceTrackerCustomizer<IServerFacto
* @param scheduler
* @return true
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public boolean addScheduler(MScheduler scheduler) {
String serverId = scheduler.getServerID();
if (getServer(serverId) != null)
@ -226,6 +227,8 @@ public class AdempiereServerMgr implements ServiceTrackerCustomizer<IServerFacto
continue;
// Do start
// replace
Env.setContext(Env.getCtx(), Env.AD_CLIENT_ID, server.getServer().getModel().getAD_Client_ID());
server.getServer().recalculateSleepMS();
server.start();
}
catch (Exception e)
@ -233,6 +236,7 @@ public class AdempiereServerMgr implements ServiceTrackerCustomizer<IServerFacto
log.log(Level.SEVERE, "Server: " + server, e);
}
} // for all servers
Env.setContext(Env.getCtx(), Env.AD_CLIENT_ID, 0);
// Final Check
int noRunning = 0;
@ -279,6 +283,7 @@ public class AdempiereServerMgr implements ServiceTrackerCustomizer<IServerFacto
try
{
// replace
Env.setContext(Env.getCtx(), Env.AD_CLIENT_ID, server.getServer().getModel().getAD_Client_ID());
server.getServer().recalculateSleepMS();
server.start();
}
@ -287,6 +292,10 @@ public class AdempiereServerMgr implements ServiceTrackerCustomizer<IServerFacto
log.log(Level.SEVERE, "Server=" + serverID, e);
return false;
}
finally
{
Env.setContext(Env.getCtx(), Env.AD_CLIENT_ID, 0);
}
if (log.isLoggable(Level.INFO)) log.info(server.toString());
return (server.scheduleFuture != null && !server.scheduleFuture.isDone());
} // startIt

View File

@ -18,7 +18,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import org.adempiere.base.Core;
import org.adempiere.webui.ClientInfo;
import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.Label;
@ -34,6 +33,7 @@ import org.adempiere.webui.util.ZKUpdateUtil;
import org.adempiere.webui.window.FDialog;
import org.compiere.model.GridField;
import org.compiere.model.GridTab;
import org.compiere.model.GridTable;
import org.compiere.model.GridWindow;
import org.compiere.model.MField;
import org.compiere.model.MLookup;
@ -66,9 +66,10 @@ public class WQuickEntry extends Window implements EventListener<Event>, ValueCh
/**
*
*/
private static final long serialVersionUID = -8530102231615195037L;
private static final long serialVersionUID = -1397302187339942732L;
public static final String QUICK_ENTRY_MODE = "_QUICK_ENTRY_MODE_";
public static final String QUICK_ENTRY_CALLER_WINDOW = "_QUICK_ENTRY_CALLER_WINDOW_";
private static CLogger log = CLogger.getCLogger(WQuickEntry.class);
@ -119,6 +120,7 @@ public class WQuickEntry extends Window implements EventListener<Event>, ValueCh
}
Env.setContext(Env.getCtx(), m_WindowNo, QUICK_ENTRY_MODE, "Y");
Env.setContext(Env.getCtx(), m_WindowNo, QUICK_ENTRY_CALLER_WINDOW, parent_WindowNo);
initPOs();
} // WQuickEntry
@ -530,12 +532,16 @@ public class WQuickEntry extends Window implements EventListener<Event>, ValueCh
WEditor editor = quickEditors.get(idx);
GridTab gridTab = field.getGridTab();
String columnName = field.getColumnName();
GridTable mTable = gridTab.getTableModel();
int row = gridTab.getCurrentRow();
int col = mTable.findColumn(columnName);
// process dependencies and callouts for the changed field
if (evt.getSource() instanceof WLocationEditor && evt.getNewValue() == null && editor.getValue() != null) {
// ignore first call of WLocationEditor valuechange set to null
// it will be called later with correct value
// see WLocationEditor firing twice ValueChangeEvent (first with null and then with value)
} else {
mTable.setValueAt(evt.getNewValue(), row, col);
field.setValue(evt.getNewValue(), field.getGridTab().getTableModel().isInserting());
gridTab.processFieldChange(field);
}
@ -553,12 +559,8 @@ public class WQuickEntry extends Window implements EventListener<Event>, ValueCh
mLookup.refresh();
}
}
} // for all dependent fields
if ( dependants.size() > 0
|| field.getCallout().length() > 0
|| Core.findCallout(gridTab.getTableName(), columnName).size() > 0) {
dynamicDisplay();
}
dynamicDisplay();
}
}
}
@ -570,8 +572,13 @@ public class WQuickEntry extends Window implements EventListener<Event>, ValueCh
{
for (int idxf = 0; idxf < quickFields.size(); idxf++) {
GridField field = quickFields.get(idxf);
GridTab gridTab = field.getGridTab();
String columnName = field.getColumnName();
GridTable mTable = gridTab.getTableModel();
int row = gridTab.getCurrentRow();
int col = mTable.findColumn(columnName);
WEditor editor = quickEditors.get(idxf);
editor.setValue(field.getValue());
editor.setValue(mTable.getValueAt(row, col)); //In case a callout changed the value and it is not reflected in field yet
editor.setReadWrite(field.isEditable(true));
editor.setVisible(field.isDisplayed(true));
}

View File

@ -1566,6 +1566,7 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
@Override
protected void executeQuery() {
if (!isRequeryByRunSuccessProcess)
prepareTable();
super.executeQuery();
if (ClientInfo.maxHeight(ClientInfo.SMALL_HEIGHT-1) ||

View File

@ -1,4 +1,4 @@
osgi.framework=file\:../plugins/org.eclipse.osgi_3.12.50.v20170928-1321.jar
osgi.framework=file\:../plugins/org.eclipse.osgi_3.12.100.v20180210-1608.jar
osgi.install.area=director
equinox.use.ds=true
osgi.bundles=org.eclipse.core.net@start,\