Merge release-7.1 into master

This commit is contained in:
Carlos Ruiz 2020-01-25 15:14:33 +01:00
commit 55dc83de87
18 changed files with 192 additions and 125 deletions

View File

@ -0,0 +1,10 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-4152 - Payment Allocation : notify user when date changes
-- 2020-01-21 02:03:32
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 ('I','Allocation date updated',0,0,'Y',TO_DATE('2020-01-21 14:03:32','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-01-21 14:03:32','YYYY-MM-DD HH24:MI:SS'),100,200592,'AllocationDateUpdated','D','c5cb7231-9ccc-4219-aaab-46ac3de8a372')
;
SELECT register_migration_script('202001211400_IDEMPIERE-4152.sql') FROM dual
;

View File

@ -0,0 +1,4 @@
-- placeholder - just for postgresql
SELECT register_migration_script('202001211654_IDEMPIERE-4143.sql') FROM dual
;

View File

@ -0,0 +1,7 @@
-- IDEMPIERE-4152 - Payment Allocation : notify user when date changes
-- 2020-01-21 02:03:32
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 ('I','Allocation date updated',0,0,'Y',TO_TIMESTAMP('2020-01-21 14:03:32','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-01-21 14:03:32','YYYY-MM-DD HH24:MI:SS'),100,200592,'AllocationDateUpdated','D','c5cb7231-9ccc-4219-aaab-46ac3de8a372')
;
SELECT register_migration_script('202001211400_IDEMPIERE-4152.sql') FROM dual
;

View File

@ -0,0 +1,4 @@
ALTER FUNCTION documentNo(numeric) OWNER TO adempiere;
SELECT register_migration_script('202001211654_IDEMPIERE-4143.sql') FROM dual
;

View File

@ -549,7 +549,8 @@ public class Doc_MatchPO extends Doc
if (m_oLine.getC_Currency_ID() != as.getC_Currency_ID())
{
MOrder order = m_oLine.getParent();
if(MAcctSchema.COSTINGMETHOD_AveragePO.equals(as.getCostingMethod()))
MProduct product = new MProduct(getCtx(), m_oLine.getM_Product_ID(), getTrxName());
if(MAcctSchema.COSTINGMETHOD_AveragePO.equals(product.getCostingMethod(as)))
{
orderCost = mPO[i].getM_InOutLine().getC_OrderLine().getPriceActual();
Timestamp dateAcct = mPO[i].getM_InOutLine().getM_InOut().getDateAcct();

View File

@ -63,6 +63,7 @@ public class MColumn extends X_AD_Column
* Get MColumn from Cache
* @param ctx context
* @param AD_Column_ID id
* @param trxName trx
* @return MColumn
*/
public static MColumn get(Properties ctx, int AD_Column_ID, String trxName)
@ -807,11 +808,11 @@ public class MColumn extends X_AD_Column
if (DisplayType.TableDir == refid || (DisplayType.Search == refid && getAD_Reference_Value_ID() == 0)) {
foreignTable = getColumnName().substring(0, getColumnName().length()-3);
} else if (DisplayType.Table == refid || DisplayType.Search == refid) {
MReference ref = MReference.get(getCtx(), getAD_Reference_Value_ID());
MReference ref = MReference.get(getCtx(), getAD_Reference_Value_ID(), get_TrxName());
if (MReference.VALIDATIONTYPE_TableValidation.equals(ref.getValidationType())) {
int cnt = DB.getSQLValueEx(get_TrxName(), "SELECT COUNT(*) FROM AD_Ref_Table WHERE AD_Reference_ID=?", getAD_Reference_Value_ID());
if (cnt == 1) {
MRefTable rt = MRefTable.get(getCtx(), getAD_Reference_Value_ID());
MRefTable rt = MRefTable.get(getCtx(), getAD_Reference_Value_ID(), get_TrxName());
if (rt != null)
foreignTable = rt.getAD_Table().getTableName();
}

View File

@ -297,9 +297,9 @@ public class MProcessPara extends X_AD_Process_Para
|| (DisplayType.Search == getAD_Reference_ID() && getAD_Reference_Value_ID() == 0)) {
foreignTable = getColumnName().substring(0, getColumnName().length()-3);
} else if (DisplayType.Table == getAD_Reference_ID() || DisplayType.Search == getAD_Reference_ID()) {
MReference ref = MReference.get(getCtx(), getAD_Reference_Value_ID());
MReference ref = MReference.get(getCtx(), getAD_Reference_Value_ID(), get_TrxName());
if (MReference.VALIDATIONTYPE_TableValidation.equals(ref.getValidationType())) {
MRefTable rt = MRefTable.get(getCtx(), getAD_Reference_Value_ID());
MRefTable rt = MRefTable.get(getCtx(), getAD_Reference_Value_ID(), get_TrxName());
if (rt != null)
foreignTable = rt.getAD_Table().getTableName();
}

View File

@ -27,7 +27,7 @@ public class MRefTable extends X_AD_Ref_Table
/**
*
*/
private static final long serialVersionUID = -699466856436251075L;
private static final long serialVersionUID = -3595900192339578282L;
/**
* Standard Constructor
@ -68,19 +68,27 @@ public class MRefTable extends X_AD_Ref_Table
/** Ref Table Cache */
private static CCache<Integer,MRefTable> s_cache = new CCache<Integer,MRefTable>(Table_Name, 20);
public static MRefTable get (Properties ctx, int AD_Reference_ID)
{
return get (ctx, AD_Reference_ID, null);
}
/**
* Get from Cache
* @param ctx context
* @param AD_Reference_ID id
* @param trxName trx
* @return category
*/
public static MRefTable get (Properties ctx, int AD_Reference_ID)
public static MRefTable get (Properties ctx, int AD_Reference_ID, String trxName)
{
Integer ii = Integer.valueOf(AD_Reference_ID);
MRefTable retValue = (MRefTable)s_cache.get(ii);
if (retValue != null)
if (retValue != null) {
retValue.set_TrxName(trxName);
return retValue;
retValue = new MRefTable (ctx, AD_Reference_ID, null);
}
retValue = new MRefTable (ctx, AD_Reference_ID, trxName);
if (retValue.get_ID () != 0)
s_cache.put (AD_Reference_ID, retValue);
return retValue;

View File

@ -33,7 +33,7 @@ public class MReference extends X_AD_Reference {
/**
*
*/
private static final long serialVersionUID = 119105464164520763L;
private static final long serialVersionUID = 343092563490562893L;
/**
* Standard Constructor
@ -61,19 +61,27 @@ public class MReference extends X_AD_Reference {
/** Reference Cache */
private static CCache<Integer,MReference> s_cache = new CCache<Integer,MReference>(Table_Name, 20);
public static MReference get (Properties ctx, int AD_Reference_ID)
{
return get(ctx, AD_Reference_ID, null);
}
/**
* Get from Cache
* @param ctx context
* @param AD_Reference_ID id
* @param trxName trx
* @return category
*/
public static MReference get (Properties ctx, int AD_Reference_ID)
public static MReference get (Properties ctx, int AD_Reference_ID, String trxName)
{
Integer ii = Integer.valueOf(AD_Reference_ID);
MReference retValue = (MReference)s_cache.get(ii);
if (retValue != null)
if (retValue != null) {
retValue.set_TrxName(trxName);
return retValue;
retValue = new MReference (ctx, AD_Reference_ID, null);
}
retValue = new MReference (ctx, AD_Reference_ID, trxName);
if (retValue.get_ID () != 0)
s_cache.put (AD_Reference_ID, retValue);
return retValue;

View File

@ -9,6 +9,9 @@ import java.util.Properties;
import org.compiere.util.CCache;
import org.compiere.util.Env;
import org.compiere.util.Evaluatee;
import org.compiere.util.Evaluator;
import org.compiere.util.Util;
/**
* @author hengsin
@ -18,7 +21,7 @@ public class MStyle extends X_AD_Style {
/**
*
*/
private static final long serialVersionUID = 4988653330824933725L;
private static final long serialVersionUID = 712675285511854305L;
/** Cache */
private static CCache<Integer,MStyle> s_cache = new CCache<Integer,MStyle>(Table_Name, 30, 60);
@ -55,4 +58,28 @@ public class MStyle extends X_AD_Style {
}
return m_lines;
}
public String buildStyle(String defaultTheme, Evaluatee evaluatee) {
X_AD_StyleLine[] lines = getStyleLines();
StringBuilder styleBuilder = new StringBuilder();
for (X_AD_StyleLine line : lines)
{
String inlineStyle = line.getInlineStyle().trim();
String displayLogic = line.getDisplayLogic();
String theme = line.getTheme();
if (!Util.isEmpty(theme)) {
if (!theme.equals(defaultTheme))
continue;
}
if (!Util.isEmpty(displayLogic))
{
if (!Evaluator.evaluateLogic(evaluatee, displayLogic))
continue;
}
if (styleBuilder.length() > 0 && !(styleBuilder.charAt(styleBuilder.length()-1)==';'))
styleBuilder.append("; ");
styleBuilder.append(inlineStyle);
}
return styleBuilder.toString();
}
}

View File

@ -20,6 +20,8 @@ the License.
package fi.jawsy.jawwa.zk.atmosphere;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import org.atmosphere.cpr.AtmosphereResource;
@ -58,6 +60,7 @@ public class AtmosphereServerPush implements ServerPush {
private ThreadInfo _active;
private ExecutionCarryOver _carryOver;
private final Object _mutex = new Object();
private List<Schedule<Event>> schedules = new ArrayList<>();
public AtmosphereServerPush() {
String timeoutString = Library.getProperty("fi.jawsy.jawwa.zk.atmosphere.timeout");
@ -155,19 +158,42 @@ public class AtmosphereServerPush implements ServerPush {
return _active != null && _active.nActive > 0;
}
@Override
@SuppressWarnings("unchecked")
@Override
public void onPiggyback() {
Schedule<Event>[] pendings = null;
synchronized (schedules) {
if (!schedules.isEmpty()) {
pendings = schedules.toArray(new Schedule[0]);
schedules = new ArrayList<>();
}
}
if (pendings != null && pendings.length > 0) {
for(Schedule<Event> p : pendings) {
p.scheduler.schedule(p.task, p.event);
}
}
}
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public <T extends Event> void schedule(EventListener<T> task, T event,
Scheduler<T> scheduler) {
scheduler.schedule(task, event);
try {
commitResponse();
} catch (IOException e) {
log.error(e.getLocalizedMessage(), e);
}
if (Executions.getCurrent() == null) {
//save for schedule at on piggyback event
synchronized (schedules) {
schedules.add(new Schedule(task, event, scheduler));
}
try {
commitResponse();
} catch (IOException e) {
log.error(e.getMessage(), e);
}
} else {
//in event listener thread, can schedule immediately
scheduler.schedule(task, event);
}
}
@Override
@ -238,4 +264,16 @@ public class AtmosphereServerPush implements ServerPush {
@Override
public void resume() {
}
private class Schedule<T extends Event> {
private EventListener<T> task;
private T event;
private Scheduler<T> scheduler;
private Schedule(EventListener<T> task, T event, Scheduler<T> scheduler) {
this.task = task;
this.event = event;
this.scheduler = scheduler;
}
}
}

View File

@ -523,9 +523,12 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
Env.setContext(properties, Env.LANGUAGE, Env.getContext(Env.getCtx(), Env.LANGUAGE));
Env.setContext(properties, AEnv.LOCALE, Env.getContext(Env.getCtx(), AEnv.LOCALE));
Locale locale = (Locale) Executions.getCurrent().getDesktop().getSession().getAttribute(Attributes.PREFERRED_LOCALE);
Desktop desktop = Executions.getCurrent().getDesktop();
Locale locale = (Locale) desktop.getSession().getAttribute(Attributes.PREFERRED_LOCALE);
HttpServletRequest httpRequest = (HttpServletRequest) Executions.getCurrent().getNativeRequest();
if (desktop.isServerPushEnabled())
desktop.enableServerPush(false);
Session session = logout0();
//clear context and invalidate session

View File

@ -57,6 +57,7 @@ import org.adempiere.webui.editor.WebEditorFactory;
import org.adempiere.webui.event.ContextMenuListener;
import org.adempiere.webui.panel.HelpController;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.GridTabDataBinder;
import org.adempiere.webui.util.TreeUtils;
import org.adempiere.webui.util.ZKUpdateUtil;
@ -71,6 +72,7 @@ import org.compiere.model.I_AD_Preference;
import org.compiere.model.MColumn;
import org.compiere.model.MPreference;
import org.compiere.model.MRole;
import org.compiere.model.MStyle;
import org.compiere.model.MSysConfig;
import org.compiere.model.MTab;
import org.compiere.model.MTable;
@ -736,6 +738,25 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
Label label = new Label(field.getHeader());
Div div = new Div();
div.setSclass("form-label-heading");
if (field.getAD_FieldStyle_ID() > 0) {
MStyle style = MStyle.get(Env.getCtx(), field.getAD_FieldStyle_ID());
String cssStyle = style.buildStyle(ThemeManager.getTheme(), new Evaluatee() {
@Override
public String get_ValueAsString(String variableName) {
return field.get_ValueAsString(variableName);
}
});
if (cssStyle != null && cssStyle.startsWith(MStyle.SCLASS_PREFIX)) {
String sclass = cssStyle.substring(MStyle.SCLASS_PREFIX.length());
div.setSclass(sclass);
} else if (style != null && cssStyle.startsWith(MStyle.ZCLASS_PREFIX)) {
String zclass = cssStyle.substring(MStyle.ZCLASS_PREFIX.length());
div.setZclass(zclass);
} else {
div.setStyle(cssStyle);
}
}
row.appendCellChild(createSpacer());
div.appendChild(label);
row.appendCellChild(div);

View File

@ -44,10 +44,8 @@ import org.compiere.model.GridField;
import org.compiere.model.GridTab;
import org.compiere.model.MStyle;
import org.compiere.model.MSysConfig;
import org.compiere.model.X_AD_StyleLine;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.Evaluator;
import org.compiere.util.Msg;
import org.compiere.util.Util;
import org.zkoss.zk.au.out.AuScript;
@ -279,27 +277,7 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
GridRowCtx gridRowCtx = new GridRowCtx(Env.getCtx(), gridTab, rowIndex);
MStyle style = MStyle.get(Env.getCtx(), AD_Style_ID);
X_AD_StyleLine[] lines = style.getStyleLines();
StringBuilder styleBuilder = new StringBuilder();
for (X_AD_StyleLine line : lines)
{
String inlineStyle = line.getInlineStyle().trim();
String displayLogic = line.getDisplayLogic();
String theme = line.getTheme();
if (!Util.isEmpty(theme)) {
if (!ThemeManager.getTheme().equals(theme))
continue;
}
if (!Util.isEmpty(displayLogic))
{
if (!Evaluator.evaluateLogic(gridRowCtx, displayLogic))
continue;
}
if (styleBuilder.length() > 0 && !(styleBuilder.charAt(styleBuilder.length()-1)==';'))
styleBuilder.append("; ");
styleBuilder.append(inlineStyle);
}
setComponentStyle(component, styleBuilder.toString());
setComponentStyle(component, style.buildStyle(ThemeManager.getTheme(), gridRowCtx));
}
protected void setComponentStyle(HtmlBasedComponent component, String style) {

View File

@ -66,6 +66,7 @@ import org.compiere.util.TrxRunnable;
import org.compiere.util.Util;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.Div;
@ -703,10 +704,15 @@ public class WAllocation extends Allocation
paymentInfo.setText(calculatePayment(paymentTable, multiCurrency.isSelected()));
invoiceInfo.setText(calculateInvoice(invoiceTable, multiCurrency.isSelected()));
// Set AllocationDate
if (allocDate != null)
dateField.setValue(allocDate);
if (allocDate != null) {
if (! allocDate.equals(dateField.getValue())) {
Clients.showNotification(Msg.getMsg(Env.getCtx(), "AllocationDateUpdated"), Clients.NOTIFICATION_TYPE_INFO, dateField.getComponent(), "start_before", -1, false);
dateField.setValue(allocDate);
}
}
// Set Allocation Currency
allocCurrencyLabel.setText(currencyPick.getDisplay());
// Difference

View File

@ -34,12 +34,9 @@ import org.compiere.minigrid.IDColumn;
import org.compiere.model.GridField;
import org.compiere.model.MInfoColumn;
import org.compiere.model.MStyle;
import org.compiere.model.X_AD_StyleLine;
import org.compiere.util.Env;
import org.compiere.util.Evaluatee;
import org.compiere.util.Evaluator;
import org.compiere.util.KeyNamePair;
import org.compiere.util.Util;
import org.zkoss.zul.Listcell;
public class WInfoWindowListItemRenderer extends WListItemRenderer
@ -130,52 +127,28 @@ public class WInfoWindowListItemRenderer extends WListItemRenderer
if (gridField.getAD_FieldStyle_ID() > 0)
{
MStyle style = MStyle.get(Env.getCtx(), gridField.getAD_FieldStyle_ID());
X_AD_StyleLine[] lines = style.getStyleLines();
StringBuilder styleBuilder = new StringBuilder();
for (X_AD_StyleLine line : lines)
{
String inlineStyle = line.getInlineStyle().trim();
String displayLogic = line.getDisplayLogic();
String theme = line.getTheme();
if (!Util.isEmpty(theme)) {
if (!ThemeManager.getTheme().equals(theme))
continue;
}
if (!Util.isEmpty(displayLogic))
{
Evaluatee ev = new Evaluatee() {
@Override
public String get_ValueAsString(String variableName) {
String value = null;
int idx = 0;
for (MInfoColumn ic : gridDisplayedInfoColumns)
{
if (ic != null && ic.getColumnName().equals(variableName))
{
value = String.valueOf(table.getValueAt(rowIndex, idx));
break;
}
idx++;
}
return value;
}
};
if (!Evaluator.evaluateLogic(ev, displayLogic))
continue;
}
if (styleBuilder.length() > 0 && !(styleBuilder.charAt(styleBuilder.length()-1)==';'))
styleBuilder.append("; ");
styleBuilder.append(inlineStyle);
}
//devCoffee #5960
String styleStr = styleBuilder.toString();
String styleStr = style.buildStyle(ThemeManager.getTheme(), new Evaluatee() {
@Override
public String get_ValueAsString(String variableName) {
String value = null;
int idx = 0;
for (MInfoColumn ic : gridDisplayedInfoColumns)
{
if (ic != null && ic.getColumnName().equals(variableName))
{
value = String.valueOf(table.getValueAt(rowIndex, idx));
break;
}
idx++;
}
return value;
}
});
if (styleStr != null && styleStr.startsWith(MStyle.SCLASS_PREFIX)) {
String sclass = styleStr.substring(MStyle.SCLASS_PREFIX.length());
listcell.setSclass(sclass);

View File

@ -44,11 +44,9 @@ import org.compiere.model.GridField;
import org.compiere.model.GridTab;
import org.compiere.model.MRole;
import org.compiere.model.MStyle;
import org.compiere.model.X_AD_StyleLine;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.Evaluatee;
import org.compiere.util.Evaluator;
import org.compiere.util.Msg;
import org.compiere.util.Util;
import org.zkoss.zk.ui.Component;
@ -647,27 +645,7 @@ public abstract class WEditor implements EventListener<Event>, PropertyChangeLis
protected String buildStyle(int AD_Style_ID) {
MStyle style = MStyle.get(Env.getCtx(), AD_Style_ID);
X_AD_StyleLine[] lines = style.getStyleLines();
StringBuilder styleBuilder = new StringBuilder();
for (X_AD_StyleLine line : lines)
{
String inlineStyle = line.getInlineStyle().trim();
String displayLogic = line.getDisplayLogic();
String theme = line.getTheme();
if (!Util.isEmpty(theme)) {
if (!ThemeManager.getTheme().equals(theme))
continue;
}
if (!Util.isEmpty(displayLogic))
{
if (!Evaluator.evaluateLogic(getStyleEvaluatee(), displayLogic))
continue;
}
if (styleBuilder.length() > 0 && !(styleBuilder.charAt(styleBuilder.length()-1)==';'))
styleBuilder.append("; ");
styleBuilder.append(inlineStyle);
}
return styleBuilder.toString();
return style.buildStyle(ThemeManager.getTheme(), getStyleEvaluatee());
}
/**

View File

@ -57,14 +57,14 @@
polling - org.zkoss.zkex.ui.impl.PollingServerPush
comet - org.zkoss.zkmax.ui.comet.CometServerPush ( enterprise edition only )
-->
<!-- device-config>
<device-type>ajax</device-type>
<server-push-class>fi.jawsy.jawwa.zk.atmosphere.AtmosphereServerPush</server-push-class>
</device-config -->
<device-config>
<device-type>ajax</device-type>
<server-push-class>org.idempiere.ui.zk.websocket.WebSocketServerPush</server-push-class>
<server-push-class>fi.jawsy.jawwa.zk.atmosphere.AtmosphereServerPush</server-push-class>
</device-config>
<!-- device-config>
<device-type>ajax</device-type>
<server-push-class>org.idempiere.ui.zk.websocket.WebSocketServerPush</server-push-class>
</device-config -->
<!-- true for better performance and lower resource usage -->
<system-config>