IDEMPIERE-417 Update BPLocation.Name
This commit is contained in:
parent
af759b7134
commit
d20678cab8
|
@ -167,10 +167,10 @@ public class MBPartnerLocation extends X_C_BPartner_Location {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Set New Name
|
// Set New Name
|
||||||
if (!newRecord)
|
if (".".equals(getName())) {
|
||||||
return true;
|
MLocation address = getLocation(true);
|
||||||
MLocation address = getLocation(true);
|
setName(getBPLocName(address));
|
||||||
setName(getBPLocName(address));
|
}
|
||||||
return true;
|
return true;
|
||||||
} // beforeSave
|
} // beforeSave
|
||||||
|
|
||||||
|
|
|
@ -656,12 +656,14 @@ public class MLocation extends X_C_Location implements Comparator<Object>
|
||||||
+ " OR C_LocTo_ID=" + getC_Location_ID() + ")", get_TrxName());
|
+ " OR C_LocTo_ID=" + getC_Location_ID() + ")", get_TrxName());
|
||||||
|
|
||||||
//Update BP_Location name IDEMPIERE 417
|
//Update BP_Location name IDEMPIERE 417
|
||||||
int bplID = DB.getSQLValueEx(get_TrxName(), "SELECT C_BPartner_Location_ID FROM C_BPartner_Location WHERE C_Location_ID = " + getC_Location_ID());
|
if (get_TrxName().startsWith(PO.LOCAL_TRX_PREFIX)) { // saved without trx
|
||||||
if (bplID>0)
|
int bplID = DB.getSQLValueEx(get_TrxName(), "SELECT C_BPartner_Location_ID FROM C_BPartner_Location WHERE C_Location_ID = " + getC_Location_ID());
|
||||||
{
|
if (bplID>0)
|
||||||
MBPartnerLocation bpl = new MBPartnerLocation(getCtx(), bplID, get_TrxName());
|
{
|
||||||
bpl.setName(bpl.getBPLocName(this));
|
MBPartnerLocation bpl = new MBPartnerLocation(getCtx(), bplID, get_TrxName());
|
||||||
bpl.saveEx();
|
bpl.setName(bpl.getBPLocName(this));
|
||||||
|
bpl.saveEx();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
} // afterSave
|
} // afterSave
|
||||||
|
|
|
@ -353,7 +353,7 @@ public class VLocation extends JComponent
|
||||||
//
|
//
|
||||||
log.config( "actionPerformed - " + m_value);
|
log.config( "actionPerformed - " + m_value);
|
||||||
VLocationDialog ld = new VLocationDialog(AEnv.getFrame(this),
|
VLocationDialog ld = new VLocationDialog(AEnv.getFrame(this),
|
||||||
Msg.getMsg(Env.getCtx(), "Location"), m_value);
|
Msg.getMsg(Env.getCtx(), "Location"), m_value, m_GridField);
|
||||||
ld.setVisible(true);
|
ld.setVisible(true);
|
||||||
Object oldValue = getValue();
|
Object oldValue = getValue();
|
||||||
m_value = ld.getValue();
|
m_value = ld.getValue();
|
||||||
|
@ -364,27 +364,11 @@ public class VLocation extends JComponent
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Data Binding
|
// Data Binding
|
||||||
try
|
int C_Location_ID = 0;
|
||||||
{
|
if (m_value != null)
|
||||||
int C_Location_ID = 0;
|
C_Location_ID = m_value.getC_Location_ID();
|
||||||
if (m_value != null)
|
Integer ii = new Integer(C_Location_ID);
|
||||||
C_Location_ID = m_value.getC_Location_ID();
|
setValue(ii);
|
||||||
Integer ii = new Integer(C_Location_ID);
|
|
||||||
|
|
||||||
if (C_Location_ID != 0)
|
|
||||||
fireVetoableChange(m_columnName, oldValue, ii);
|
|
||||||
setValue(ii);
|
|
||||||
if (ii.equals(oldValue) && m_GridTab != null && m_GridField != null)
|
|
||||||
{
|
|
||||||
// force Change - user does not realize that embedded object is already saved.
|
|
||||||
m_GridTab.processFieldChange(m_GridField);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (PropertyVetoException pve)
|
|
||||||
{
|
|
||||||
log.log(Level.SEVERE, "VLocation.actionPerformed", pve);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // actionPerformed
|
} // actionPerformed
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -39,6 +39,8 @@ import javax.swing.SwingConstants;
|
||||||
import org.compiere.apps.ADialog;
|
import org.compiere.apps.ADialog;
|
||||||
import org.compiere.apps.AEnv;
|
import org.compiere.apps.AEnv;
|
||||||
import org.compiere.apps.ConfirmPanel;
|
import org.compiere.apps.ConfirmPanel;
|
||||||
|
import org.compiere.model.GridField;
|
||||||
|
import org.compiere.model.MBPartnerLocation;
|
||||||
import org.compiere.model.MCountry;
|
import org.compiere.model.MCountry;
|
||||||
import org.compiere.model.MLocation;
|
import org.compiere.model.MLocation;
|
||||||
import org.compiere.model.MOrgInfo;
|
import org.compiere.model.MOrgInfo;
|
||||||
|
@ -50,8 +52,10 @@ import org.compiere.swing.CLabel;
|
||||||
import org.compiere.swing.CPanel;
|
import org.compiere.swing.CPanel;
|
||||||
import org.compiere.swing.CTextField;
|
import org.compiere.swing.CTextField;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
|
import org.compiere.util.Trx;
|
||||||
|
|
||||||
import com.akunagroup.uk.postcode.AddressLookupInterface;
|
import com.akunagroup.uk.postcode.AddressLookupInterface;
|
||||||
import com.akunagroup.uk.postcode.Postcode;
|
import com.akunagroup.uk.postcode.Postcode;
|
||||||
|
@ -90,6 +94,8 @@ public class VLocationDialog extends CDialog
|
||||||
|
|
||||||
private int m_WindowNo = 0;
|
private int m_WindowNo = 0;
|
||||||
|
|
||||||
|
private GridField m_GridField = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
|
@ -99,7 +105,12 @@ public class VLocationDialog extends CDialog
|
||||||
*/
|
*/
|
||||||
public VLocationDialog (Frame frame, String title, MLocation location)
|
public VLocationDialog (Frame frame, String title, MLocation location)
|
||||||
{
|
{
|
||||||
|
this(frame, title, location, null);
|
||||||
|
} // VLocationDialog
|
||||||
|
|
||||||
|
public VLocationDialog(Frame frame, String title, MLocation location, GridField gridField) {
|
||||||
super(frame, title, true);
|
super(frame, title, true);
|
||||||
|
m_GridField = gridField;
|
||||||
//m_WindowNo = WindowNo;
|
//m_WindowNo = WindowNo;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -143,7 +154,7 @@ public class VLocationDialog extends CDialog
|
||||||
fOnline.addActionListener(this);
|
fOnline.addActionListener(this);
|
||||||
fRegion.addActionListener(this);
|
fRegion.addActionListener(this);
|
||||||
AEnv.positionCenterWindow(frame, this);
|
AEnv.positionCenterWindow(frame, this);
|
||||||
} // VLocationDialog
|
}
|
||||||
|
|
||||||
private boolean m_change = false;
|
private boolean m_change = false;
|
||||||
private MLocation m_location;
|
private MLocation m_location;
|
||||||
|
@ -574,6 +585,8 @@ public class VLocationDialog extends CDialog
|
||||||
*/
|
*/
|
||||||
private boolean action_OK()
|
private boolean action_OK()
|
||||||
{
|
{
|
||||||
|
Trx trx = Trx.get(Trx.createTrxName("VLocationDialog"), true);
|
||||||
|
m_location.set_TrxName(trx.getTrxName());
|
||||||
m_location.setAddress1(fAddress1.getText());
|
m_location.setAddress1(fAddress1.getText());
|
||||||
m_location.setAddress2(fAddress2.getText());
|
m_location.setAddress2(fAddress2.getText());
|
||||||
m_location.setAddress3(fAddress3.getText());
|
m_location.setAddress3(fAddress3.getText());
|
||||||
|
@ -593,14 +606,35 @@ public class VLocationDialog extends CDialog
|
||||||
else
|
else
|
||||||
m_location.setC_Region_ID(0);
|
m_location.setC_Region_ID(0);
|
||||||
// Save changes
|
// Save changes
|
||||||
if(m_location.save())
|
boolean success = false;
|
||||||
|
if (m_location.save())
|
||||||
{
|
{
|
||||||
return true;
|
// IDEMPIERE-417 Force Update BPLocation.Name
|
||||||
|
if (m_GridField != null && m_GridField.getGridTab() != null
|
||||||
|
&& "C_BPartner_Location".equals(m_GridField.getGridTab().getTableName()))
|
||||||
|
{
|
||||||
|
m_GridField.getGridTab().setValue("Name", ".");
|
||||||
|
success = true;
|
||||||
|
} else {
|
||||||
|
//Update BP_Location name IDEMPIERE 417
|
||||||
|
int bplID = DB.getSQLValueEx(trx.getTrxName(), "SELECT C_BPartner_Location_ID FROM C_BPartner_Location WHERE C_Location_ID = " + m_location.getC_Location_ID());
|
||||||
|
if (bplID>0)
|
||||||
|
{
|
||||||
|
MBPartnerLocation bpl = new MBPartnerLocation(Env.getCtx(), bplID, trx.getTrxName());
|
||||||
|
bpl.setName(bpl.getBPLocName(m_location));
|
||||||
|
if (bpl.save())
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
if (success) {
|
||||||
{
|
trx.commit();
|
||||||
return false;
|
} else {
|
||||||
|
trx.rollback();
|
||||||
}
|
}
|
||||||
|
trx.close();
|
||||||
|
|
||||||
|
return success;
|
||||||
} // actionOK
|
} // actionOK
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -164,7 +164,7 @@ public class WLocationEditor extends WEditor implements EventListener<Event>, Pr
|
||||||
if ("onClick".equals(event.getName()))
|
if ("onClick".equals(event.getName()))
|
||||||
{
|
{
|
||||||
log.config( "actionPerformed - " + m_value);
|
log.config( "actionPerformed - " + m_value);
|
||||||
final WLocationDialog ld = new WLocationDialog(Msg.getMsg(Env.getCtx(), "Location"), m_value);
|
final WLocationDialog ld = new WLocationDialog(Msg.getMsg(Env.getCtx(), "Location"), m_value, gridField);
|
||||||
ld.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
|
ld.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -179,14 +179,6 @@ public class WLocationEditor extends WEditor implements EventListener<Event>, Pr
|
||||||
if (m_value != null)
|
if (m_value != null)
|
||||||
C_Location_ID = m_value.getC_Location_ID();
|
C_Location_ID = m_value.getC_Location_ID();
|
||||||
Integer ii = new Integer(C_Location_ID);
|
Integer ii = new Integer(C_Location_ID);
|
||||||
// force Change - user does not realize that embedded object is already saved.
|
|
||||||
ValueChangeEvent valuechange = new ValueChangeEvent(WLocationEditor.this,getColumnName(),null,null);
|
|
||||||
fireValueChange(valuechange); // resets m_mLocation
|
|
||||||
if (C_Location_ID != 0)
|
|
||||||
{
|
|
||||||
ValueChangeEvent vc = new ValueChangeEvent(WLocationEditor.this,getColumnName(),null,ii);
|
|
||||||
fireValueChange(vc);
|
|
||||||
}
|
|
||||||
setValue(ii);
|
setValue(ii);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -36,13 +36,17 @@ import org.adempiere.webui.component.Panel;
|
||||||
import org.adempiere.webui.component.Row;
|
import org.adempiere.webui.component.Row;
|
||||||
import org.adempiere.webui.component.Textbox;
|
import org.adempiere.webui.component.Textbox;
|
||||||
import org.adempiere.webui.component.Window;
|
import org.adempiere.webui.component.Window;
|
||||||
|
import org.compiere.model.GridField;
|
||||||
|
import org.compiere.model.MBPartnerLocation;
|
||||||
import org.compiere.model.MCountry;
|
import org.compiere.model.MCountry;
|
||||||
import org.compiere.model.MLocation;
|
import org.compiere.model.MLocation;
|
||||||
import org.compiere.model.MOrgInfo;
|
import org.compiere.model.MOrgInfo;
|
||||||
import org.compiere.model.MRegion;
|
import org.compiere.model.MRegion;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
|
import org.compiere.util.Trx;
|
||||||
import org.zkoss.zk.ui.Executions;
|
import org.zkoss.zk.ui.Executions;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
import org.zkoss.zk.ui.event.EventListener;
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
|
@ -125,10 +129,16 @@ public class WLocationDialog extends Window implements EventListener
|
||||||
|
|
||||||
private Button toLink;
|
private Button toLink;
|
||||||
private Button toRoute;
|
private Button toRoute;
|
||||||
|
private GridField m_GridField = null;
|
||||||
//END
|
//END
|
||||||
|
|
||||||
public WLocationDialog(String title, MLocation location)
|
public WLocationDialog(String title, MLocation location)
|
||||||
{
|
{
|
||||||
|
this (title, location, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public WLocationDialog(String title, MLocation location, GridField gridField) {
|
||||||
|
m_GridField = gridField;
|
||||||
m_location = location;
|
m_location = location;
|
||||||
if (m_location == null)
|
if (m_location == null)
|
||||||
m_location = new MLocation (Env.getCtx(), 0, null);
|
m_location = new MLocation (Env.getCtx(), 0, null);
|
||||||
|
@ -511,7 +521,7 @@ public class WLocationDialog extends Window implements EventListener
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(action_OK())
|
if (action_OK())
|
||||||
{
|
{
|
||||||
m_change = true;
|
m_change = true;
|
||||||
inOKAction = false;
|
inOKAction = false;
|
||||||
|
@ -626,6 +636,8 @@ public class WLocationDialog extends Window implements EventListener
|
||||||
*/
|
*/
|
||||||
private boolean action_OK()
|
private boolean action_OK()
|
||||||
{
|
{
|
||||||
|
Trx trx = Trx.get(Trx.createTrxName("WLocationDialog"), true);
|
||||||
|
m_location.set_TrxName(trx.getTrxName());
|
||||||
m_location.setAddress1(txtAddress1.getValue());
|
m_location.setAddress1(txtAddress1.getValue());
|
||||||
m_location.setAddress2(txtAddress2.getValue());
|
m_location.setAddress2(txtAddress2.getValue());
|
||||||
m_location.setAddress3(txtAddress3.getValue());
|
m_location.setAddress3(txtAddress3.getValue());
|
||||||
|
@ -645,15 +657,36 @@ public class WLocationDialog extends Window implements EventListener
|
||||||
{
|
{
|
||||||
m_location.setC_Region_ID(0);
|
m_location.setC_Region_ID(0);
|
||||||
}
|
}
|
||||||
// Save chnages
|
// Save changes
|
||||||
if(m_location.save())
|
boolean success = false;
|
||||||
|
if (m_location.save())
|
||||||
{
|
{
|
||||||
return true;
|
// IDEMPIERE-417 Force Update BPLocation.Name
|
||||||
|
if (m_GridField != null && m_GridField.getGridTab() != null
|
||||||
|
&& "C_BPartner_Location".equals(m_GridField.getGridTab().getTableName()))
|
||||||
|
{
|
||||||
|
m_GridField.getGridTab().setValue("Name", ".");
|
||||||
|
success = true;
|
||||||
|
} else {
|
||||||
|
//Update BP_Location name IDEMPIERE 417
|
||||||
|
int bplID = DB.getSQLValueEx(trx.getTrxName(), "SELECT C_BPartner_Location_ID FROM C_BPartner_Location WHERE C_Location_ID = " + m_location.getC_Location_ID());
|
||||||
|
if (bplID>0)
|
||||||
|
{
|
||||||
|
MBPartnerLocation bpl = new MBPartnerLocation(Env.getCtx(), bplID, trx.getTrxName());
|
||||||
|
bpl.setName(bpl.getBPLocName(m_location));
|
||||||
|
if (bpl.save())
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
if (success) {
|
||||||
{
|
trx.commit();
|
||||||
return false;
|
} else {
|
||||||
|
trx.rollback();
|
||||||
}
|
}
|
||||||
|
trx.close();
|
||||||
|
|
||||||
|
return success;
|
||||||
} // actionOK
|
} // actionOK
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue