IDEMPIERE-3578 BPartner Location name : Preserve custom name

This commit is contained in:
Nicolas Micoud 2017-12-12 19:16:11 +01:00
parent 6d2700ac72
commit 82178fa0fd
8 changed files with 116 additions and 13 deletions

View File

@ -0,0 +1,34 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-3578 - BPartner Location name : Preserve custom name
-- Dec 11, 2017 9:21:24 AM CET
INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,PrintName,EntityType,AD_Element_UU) VALUES (203147,0,0,'Y',TO_DATE('2017-12-11 09:21:23','YYYY-MM-DD HH24:MI:SS'),0,TO_DATE('2017-12-11 09:21:23','YYYY-MM-DD HH24:MI:SS'),0,'IsPreserveCustomName','Preserve custom name','Preserve custom name','D','1f44e2a6-8a98-4a7f-9943-b206a882e20e')
;
-- Dec 11, 2017 9:22:24 AM CET
INSERT INTO AD_Column (AD_Column_ID,Version,Name,AD_Table_ID,ColumnName,DefaultValue,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure) VALUES (213303,0,'Preserve custom name',293,'IsPreserveCustomName','N',1,'N','N','Y','N','N',0,'N',20,0,0,'Y',TO_DATE('2017-12-11 09:22:23','YYYY-MM-DD HH24:MI:SS'),0,TO_DATE('2017-12-11 09:22:23','YYYY-MM-DD HH24:MI:SS'),0,203147,'Y','N','D','N','N','N','Y','67391508-06ed-431b-9496-e24d0018b799','N',0,'N','N')
;
-- Dec 11, 2017 9:22:27 AM CET
ALTER TABLE C_BPartner_Location ADD IsPreserveCustomName CHAR(1) DEFAULT 'N' CHECK (IsPreserveCustomName IN ('Y','N')) NOT NULL
;
-- Dec 11, 2017 9:22:52 AM CET
INSERT INTO AD_Field (AD_Field_ID,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan) VALUES (205277,'Preserve custom name',222,213303,'Y',1,170,'N','N','N','N',0,0,'Y',TO_DATE('2017-12-11 09:22:51','YYYY-MM-DD HH24:MI:SS'),0,TO_DATE('2017-12-11 09:22:51','YYYY-MM-DD HH24:MI:SS'),0,'N','Y','D','5e9824ca-04a4-44a5-a1c9-24582e84336c','Y',170,2,2)
;
-- Dec 11, 2017 9:23:06 AM CET
UPDATE AD_Field SET SeqNo=150,IsDisplayed='Y' WHERE AD_Field_ID=205277
;
-- Dec 11, 2017 9:23:06 AM CET
UPDATE AD_Field SET SeqNo=160,IsDisplayed='Y' WHERE AD_Field_ID=2186
;
-- Dec 11, 2017 9:23:06 AM CET
UPDATE AD_Field SET SeqNo=170,IsDisplayed='Y' WHERE AD_Field_ID=200619
;
SELECT register_migration_script('201712110930_IDEMPIERE-3578.sql') FROM dual
;

View File

@ -0,0 +1,31 @@
-- IDEMPIERE-3578 - BPartner Location name : Preserve custom name
-- Dec 11, 2017 9:21:24 AM CET
INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,PrintName,EntityType,AD_Element_UU) VALUES (203147,0,0,'Y',TO_TIMESTAMP('2017-12-11 09:21:23','YYYY-MM-DD HH24:MI:SS'),0,TO_TIMESTAMP('2017-12-11 09:21:23','YYYY-MM-DD HH24:MI:SS'),0,'IsPreserveCustomName','Preserve custom name','Preserve custom name','D','1f44e2a6-8a98-4a7f-9943-b206a882e20e')
;
-- Dec 11, 2017 9:22:24 AM CET
INSERT INTO AD_Column (AD_Column_ID,Version,Name,AD_Table_ID,ColumnName,DefaultValue,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure) VALUES (213303,0,'Preserve custom name',293,'IsPreserveCustomName','N',1,'N','N','Y','N','N',0,'N',20,0,0,'Y',TO_TIMESTAMP('2017-12-11 09:22:23','YYYY-MM-DD HH24:MI:SS'),0,TO_TIMESTAMP('2017-12-11 09:22:23','YYYY-MM-DD HH24:MI:SS'),0,203147,'Y','N','D','N','N','N','Y','67391508-06ed-431b-9496-e24d0018b799','N',0,'N','N')
;
-- Dec 11, 2017 9:22:27 AM CET
ALTER TABLE C_BPartner_Location ADD COLUMN IsPreserveCustomName CHAR(1) DEFAULT 'N' CHECK (IsPreserveCustomName IN ('Y','N')) NOT NULL
;
-- Dec 11, 2017 9:22:52 AM CET
INSERT INTO AD_Field (AD_Field_ID,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,XPosition,ColumnSpan) VALUES (205277,'Preserve custom name',222,213303,'Y',1,170,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2017-12-11 09:22:51','YYYY-MM-DD HH24:MI:SS'),0,TO_TIMESTAMP('2017-12-11 09:22:51','YYYY-MM-DD HH24:MI:SS'),0,'N','Y','D','5e9824ca-04a4-44a5-a1c9-24582e84336c','Y',170,2,2)
;
-- Dec 11, 2017 9:23:06 AM CET
UPDATE AD_Field SET SeqNo=150,IsDisplayed='Y' WHERE AD_Field_ID=205277
;
-- Dec 11, 2017 9:23:06 AM CET
UPDATE AD_Field SET SeqNo=160,IsDisplayed='Y' WHERE AD_Field_ID=2186
;
-- Dec 11, 2017 9:23:06 AM CET
UPDATE AD_Field SET SeqNo=170,IsDisplayed='Y' WHERE AD_Field_ID=200619
;
SELECT register_migration_script('201712110930_IDEMPIERE-3578.sql') FROM dual
;

View File

@ -219,6 +219,15 @@ public interface I_C_BPartner_Location
*/ */
public boolean isPayFrom(); public boolean isPayFrom();
/** Column name IsPreserveCustomName */
public static final String COLUMNNAME_IsPreserveCustomName = "IsPreserveCustomName";
/** Set Preserve custom name */
public void setIsPreserveCustomName (boolean IsPreserveCustomName);
/** Get Preserve custom name */
public boolean isPreserveCustomName();
/** Column name IsRemitTo */ /** Column name IsRemitTo */
public static final String COLUMNNAME_IsRemitTo = "IsRemitTo"; public static final String COLUMNNAME_IsRemitTo = "IsRemitTo";

View File

@ -165,7 +165,7 @@ public class MBPartnerLocation extends X_C_BPartner_Location {
return false; return false;
// Set New Name // Set New Name
if (".".equals(getName())) { if (".".equals(getName()) && !isPreserveCustomName()) {
MLocation address = getLocation(true); MLocation address = getLocation(true);
setName(getBPLocName(address)); setName(getBPLocName(address));
} }
@ -224,6 +224,10 @@ public class MBPartnerLocation extends X_C_BPartner_Location {
} // makeUnique } // makeUnique
public String getBPLocName(MLocation address) { public String getBPLocName(MLocation address) {
if (isPreserveCustomName())
return getName();
m_uniqueName = getName(); m_uniqueName = getName();
m_unique = MSysConfig.getIntValue(MSysConfig.START_VALUE_BPLOCATION_NAME, 0, m_unique = MSysConfig.getIntValue(MSysConfig.START_VALUE_BPLOCATION_NAME, 0,
getAD_Client_ID(), getAD_Org_ID()); getAD_Client_ID(), getAD_Org_ID());

View File

@ -50,8 +50,7 @@ public class MLocation extends X_C_Location implements Comparator<Object>
/** /**
* *
*/ */
private static final long serialVersionUID = -8462972029898383163L; private static final long serialVersionUID = -4100591609253985073L;
// http://jira.idempiere.com/browse/IDEMPIERE-147 // http://jira.idempiere.com/browse/IDEMPIERE-147
public static String LOCATION_MAPS_URL_PREFIX = MSysConfig.getValue(MSysConfig.LOCATION_MAPS_URL_PREFIX); public static String LOCATION_MAPS_URL_PREFIX = MSysConfig.getValue(MSysConfig.LOCATION_MAPS_URL_PREFIX);
public static String LOCATION_MAPS_ROUTE_PREFIX = MSysConfig.getValue(MSysConfig.LOCATION_MAPS_ROUTE_PREFIX); public static String LOCATION_MAPS_ROUTE_PREFIX = MSysConfig.getValue(MSysConfig.LOCATION_MAPS_ROUTE_PREFIX);
@ -676,6 +675,8 @@ public class MLocation extends X_C_Location implements Comparator<Object>
return true; return true;
} // beforeSave } // beforeSave
public final static String updateBPLocName = "SELECT C_BPartner_Location_ID FROM C_BPartner_Location WHERE C_Location_ID = ? AND IsPreserveCustomName = 'N'";
/** /**
* After Save * After Save
* @param newRecord new * @param newRecord new
@ -700,7 +701,7 @@ public class MLocation extends X_C_Location implements Comparator<Object>
//Update BP_Location name IDEMPIERE 417 //Update BP_Location name IDEMPIERE 417
if (get_TrxName().startsWith(PO.LOCAL_TRX_PREFIX)) { // saved without trx if (get_TrxName().startsWith(PO.LOCAL_TRX_PREFIX)) { // saved without trx
int bplID = DB.getSQLValueEx(get_TrxName(), "SELECT C_BPartner_Location_ID FROM C_BPartner_Location WHERE C_Location_ID = " + getC_Location_ID()); int bplID = DB.getSQLValueEx(get_TrxName(), updateBPLocName, getC_Location_ID());
if (bplID>0) if (bplID>0)
{ {
// just trigger BPLocation name change when the location change affects the name: // just trigger BPLocation name change when the location change affects the name:

View File

@ -30,7 +30,7 @@ public class X_C_BPartner_Location extends PO implements I_C_BPartner_Location,
/** /**
* *
*/ */
private static final long serialVersionUID = 20171031L; private static final long serialVersionUID = 20171211L;
/** Standard Constructor */ /** Standard Constructor */
public X_C_BPartner_Location (Properties ctx, int C_BPartner_Location_ID, String trxName) public X_C_BPartner_Location (Properties ctx, int C_BPartner_Location_ID, String trxName)
@ -45,6 +45,8 @@ public class X_C_BPartner_Location extends PO implements I_C_BPartner_Location,
// Y // Y
setIsPayFrom (true); setIsPayFrom (true);
// Y // Y
setIsPreserveCustomName (false);
// N
setIsRemitTo (true); setIsRemitTo (true);
// Y // Y
setIsShipTo (true); setIsShipTo (true);
@ -299,6 +301,27 @@ public class X_C_BPartner_Location extends PO implements I_C_BPartner_Location,
return false; return false;
} }
/** Set Preserve custom name.
@param IsPreserveCustomName Preserve custom name */
public void setIsPreserveCustomName (boolean IsPreserveCustomName)
{
set_Value (COLUMNNAME_IsPreserveCustomName, Boolean.valueOf(IsPreserveCustomName));
}
/** Get Preserve custom name.
@return Preserve custom name */
public boolean isPreserveCustomName ()
{
Object oo = get_Value(COLUMNNAME_IsPreserveCustomName);
if (oo != null)
{
if (oo instanceof Boolean)
return ((Boolean)oo).booleanValue();
return "Y".equals(oo);
}
return false;
}
/** Set Remit-To Address. /** Set Remit-To Address.
@param IsRemitTo @param IsRemitTo
Business Partner payment address Business Partner payment address

View File

@ -92,7 +92,7 @@ public class VLocationDialog extends CDialog
/** /**
* *
*/ */
private static final long serialVersionUID = 8870275797513554720L; private static final long serialVersionUID = -8325818864115049548L;
/** Lookup result header */ /** Lookup result header */
private Object[] header = null; private Object[] header = null;
@ -787,13 +787,14 @@ public class VLocationDialog extends CDialog
{ {
// IDEMPIERE-417 Force Update BPLocation.Name // IDEMPIERE-417 Force Update BPLocation.Name
if (m_GridField != null && m_GridField.getGridTab() != null if (m_GridField != null && m_GridField.getGridTab() != null
&& "C_BPartner_Location".equals(m_GridField.getGridTab().getTableName())) && "C_BPartner_Location".equals(m_GridField.getGridTab().getTableName())
&& !m_GridField.getGridTab().getValueAsBoolean("IsPreserveCustomName"))
{ {
m_GridField.getGridTab().setValue("Name", "."); m_GridField.getGridTab().setValue("Name", ".");
success = true; success = true;
} else { } else {
//Update BP_Location name IDEMPIERE 417 //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()); int bplID = DB.getSQLValueEx(trx.getTrxName(), MLocation.updateBPLocName, m_location.getC_Location_ID());
if (bplID>0) if (bplID>0)
{ {
MBPartnerLocation bpl = new MBPartnerLocation(Env.getCtx(), bplID, trx.getTrxName()); MBPartnerLocation bpl = new MBPartnerLocation(Env.getCtx(), bplID, trx.getTrxName());

View File

@ -92,8 +92,7 @@ public class WLocationDialog extends Window implements EventListener<Event>
/** /**
* *
*/ */
private static final long serialVersionUID = 5368065537791919302L; private static final long serialVersionUID = -490669500974096990L;
private static final String LABEL_STYLE = "white-space: nowrap;"; private static final String LABEL_STYLE = "white-space: nowrap;";
/** Logger */ /** Logger */
private static CLogger log = CLogger.getCLogger(WLocationDialog.class); private static CLogger log = CLogger.getCLogger(WLocationDialog.class);
@ -1034,12 +1033,13 @@ public class WLocationDialog extends Window implements EventListener<Event>
|| (bplocname >= 3 && changedRegion) || (bplocname >= 3 && changedRegion)
) { ) {
if ( m_GridField != null && m_GridField.getGridTab() != null if ( m_GridField != null && m_GridField.getGridTab() != null
&& "C_BPartner_Location".equals(m_GridField.getGridTab().getTableName())) && "C_BPartner_Location".equals(m_GridField.getGridTab().getTableName())
&& !m_GridField.getGridTab().getValueAsBoolean("IsPreserveCustomName"))
{ {
m_GridField.getGridTab().setValue("Name", "."); m_GridField.getGridTab().setValue("Name", ".");
} else { } else {
//Update BP_Location name IDEMPIERE 417 //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()); int bplID = DB.getSQLValueEx(trx.getTrxName(), MLocation.updateBPLocName, m_location.getC_Location_ID());
if (bplID>0) if (bplID>0)
{ {
MBPartnerLocation bpl = new MBPartnerLocation(Env.getCtx(), bplID, trx.getTrxName()); MBPartnerLocation bpl = new MBPartnerLocation(Env.getCtx(), bplID, trx.getTrxName());