IDEMPIERE-5990 Create translation for BPartnerOrgLink process errors (#2181)
This commit is contained in:
parent
803081f3ef
commit
34492d1cbf
|
@ -0,0 +1,48 @@
|
||||||
|
-- IDEMPIERE-5990
|
||||||
|
SELECT register_migration_script('202401101633_IDEMPIERE-5990.sql') FROM dual;
|
||||||
|
|
||||||
|
SET SQLBLANKLINES ON
|
||||||
|
SET DEFINE OFF
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- Jan 10, 2024, 4:35:16 PM BRT
|
||||||
|
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 ('E','Business Partner has no Location',0,0,'Y',TO_TIMESTAMP('2024-01-10 16:35:16','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2024-01-10 16:35:16','YYYY-MM-DD HH24:MI:SS'),100,200863,'BPartnerHasNoLocation','D','7c582d77-f65f-4bbe-8bbe-a894754f8b34')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 10, 2024, 4:35:40 PM BRT
|
||||||
|
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 ('E','Business Partner Location has no Address',0,0,'Y',TO_TIMESTAMP('2024-01-10 16:35:40','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2024-01-10 16:35:40','YYYY-MM-DD HH24:MI:SS'),100,200864,'BPartnerLocationHasNoAddress','D','5f931e06-751a-4b18-8f7a-83dade057d0d')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 10, 2024, 4:36:19 PM BRT
|
||||||
|
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 ('E','Organization not saved',0,0,'Y',TO_TIMESTAMP('2024-01-10 16:36:19','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2024-01-10 16:36:19','YYYY-MM-DD HH24:MI:SS'),100,200865,'OrganizationNotSaved','D','656ac3ec-9e56-434a-963c-5adb7bd5b8e2')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 10, 2024, 4:36:57 PM BRT
|
||||||
|
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','Warehouse not saved',0,0,'Y',TO_TIMESTAMP('2024-01-10 16:36:57','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2024-01-10 16:36:57','YYYY-MM-DD HH24:MI:SS'),100,200866,'WarehouseNotSaved','D','935f1626-c36a-4779-878b-ab6caba4596f')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 10, 2024, 4:37:04 PM BRT
|
||||||
|
UPDATE AD_Message SET MsgType='E',Updated=TO_TIMESTAMP('2024-01-10 16:37:04','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200866
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 10, 2024, 4:37:23 PM BRT
|
||||||
|
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 ('E','Organization Info not saved',0,0,'Y',TO_TIMESTAMP('2024-01-10 16:37:23','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2024-01-10 16:37:23','YYYY-MM-DD HH24:MI:SS'),100,200867,'OrganizationInfoNotSaved','D','8960d75b-f16c-4541-b54e-f0789450bd8f')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 10, 2024, 4:37:41 PM BRT
|
||||||
|
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 ('E','Business Partner not updated',0,0,'Y',TO_TIMESTAMP('2024-01-10 16:37:41','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2024-01-10 16:37:41','YYYY-MM-DD HH24:MI:SS'),100,200868,'BPartnerNotUpdated','D','d80b80bb-1ec9-426a-b001-7da173756847')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 10, 2024, 4:37:58 PM BRT
|
||||||
|
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','Business Partner - Organization Link created',0,0,'Y',TO_TIMESTAMP('2024-01-10 16:37:58','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2024-01-10 16:37:58','YYYY-MM-DD HH24:MI:SS'),100,200869,'BPartnerOrganizationLinkCreated','D','52d110f7-2740-4631-905b-8efa7d1725dd')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 10, 2024, 4:38:01 PM BRT
|
||||||
|
UPDATE AD_Message SET MsgType='E',Updated=TO_TIMESTAMP('2024-01-10 16:38:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200869
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 10, 2024, 4:40:26 PM BRT
|
||||||
|
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 ('E','Organization {0} already linked Business Partner {1}',0,0,'Y',TO_TIMESTAMP('2024-01-10 16:40:26','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2024-01-10 16:40:26','YYYY-MM-DD HH24:MI:SS'),100,200870,'OrganizationAlreadyLinkedBusinessPartner','D','6b3757e7-bdeb-43ba-82e1-040cc9d2143b')
|
||||||
|
;
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
-- IDEMPIERE-5990
|
||||||
|
SELECT register_migration_script('202401101633_IDEMPIERE-5990.sql') FROM dual;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- Jan 10, 2024, 4:35:16 PM BRT
|
||||||
|
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 ('E','Business Partner has no Location',0,0,'Y',TO_TIMESTAMP('2024-01-10 16:35:16','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2024-01-10 16:35:16','YYYY-MM-DD HH24:MI:SS'),100,200863,'BPartnerHasNoLocation','D','7c582d77-f65f-4bbe-8bbe-a894754f8b34')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 10, 2024, 4:35:40 PM BRT
|
||||||
|
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 ('E','Business Partner Location has no Address',0,0,'Y',TO_TIMESTAMP('2024-01-10 16:35:40','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2024-01-10 16:35:40','YYYY-MM-DD HH24:MI:SS'),100,200864,'BPartnerLocationHasNoAddress','D','5f931e06-751a-4b18-8f7a-83dade057d0d')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 10, 2024, 4:36:19 PM BRT
|
||||||
|
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 ('E','Organization not saved',0,0,'Y',TO_TIMESTAMP('2024-01-10 16:36:19','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2024-01-10 16:36:19','YYYY-MM-DD HH24:MI:SS'),100,200865,'OrganizationNotSaved','D','656ac3ec-9e56-434a-963c-5adb7bd5b8e2')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 10, 2024, 4:36:57 PM BRT
|
||||||
|
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','Warehouse not saved',0,0,'Y',TO_TIMESTAMP('2024-01-10 16:36:57','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2024-01-10 16:36:57','YYYY-MM-DD HH24:MI:SS'),100,200866,'WarehouseNotSaved','D','935f1626-c36a-4779-878b-ab6caba4596f')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 10, 2024, 4:37:04 PM BRT
|
||||||
|
UPDATE AD_Message SET MsgType='E',Updated=TO_TIMESTAMP('2024-01-10 16:37:04','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200866
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 10, 2024, 4:37:23 PM BRT
|
||||||
|
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 ('E','Organization Info not saved',0,0,'Y',TO_TIMESTAMP('2024-01-10 16:37:23','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2024-01-10 16:37:23','YYYY-MM-DD HH24:MI:SS'),100,200867,'OrganizationInfoNotSaved','D','8960d75b-f16c-4541-b54e-f0789450bd8f')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 10, 2024, 4:37:41 PM BRT
|
||||||
|
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 ('E','Business Partner not updated',0,0,'Y',TO_TIMESTAMP('2024-01-10 16:37:41','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2024-01-10 16:37:41','YYYY-MM-DD HH24:MI:SS'),100,200868,'BPartnerNotUpdated','D','d80b80bb-1ec9-426a-b001-7da173756847')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 10, 2024, 4:37:58 PM BRT
|
||||||
|
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','Business Partner - Organization Link created',0,0,'Y',TO_TIMESTAMP('2024-01-10 16:37:58','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2024-01-10 16:37:58','YYYY-MM-DD HH24:MI:SS'),100,200869,'BPartnerOrganizationLinkCreated','D','52d110f7-2740-4631-905b-8efa7d1725dd')
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 10, 2024, 4:38:01 PM BRT
|
||||||
|
UPDATE AD_Message SET MsgType='E',Updated=TO_TIMESTAMP('2024-01-10 16:38:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200869
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Jan 10, 2024, 4:40:26 PM BRT
|
||||||
|
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 ('E','Organization {0} already linked Business Partner {1}',0,0,'Y',TO_TIMESTAMP('2024-01-10 16:40:26','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2024-01-10 16:40:26','YYYY-MM-DD HH24:MI:SS'),100,200870,'OrganizationAlreadyLinkedBusinessPartner','D','6b3757e7-bdeb-43ba-82e1-040cc9d2143b')
|
||||||
|
;
|
||||||
|
|
|
@ -18,12 +18,12 @@ package org.compiere.process;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.adempiere.base.annotation.Parameter;
|
||||||
import org.compiere.model.MBPartner;
|
import org.compiere.model.MBPartner;
|
||||||
import org.compiere.model.MBPartnerLocation;
|
import org.compiere.model.MBPartnerLocation;
|
||||||
import org.compiere.model.MLocator;
|
import org.compiere.model.MLocator;
|
||||||
import org.compiere.model.MOrg;
|
import org.compiere.model.MOrg;
|
||||||
import org.compiere.model.MOrgInfo;
|
import org.compiere.model.MOrgInfo;
|
||||||
import org.compiere.model.MProcessPara;
|
|
||||||
import org.compiere.model.MRole;
|
import org.compiere.model.MRole;
|
||||||
import org.compiere.model.MRoleOrgAccess;
|
import org.compiere.model.MRoleOrgAccess;
|
||||||
import org.compiere.model.MWarehouse;
|
import org.compiere.model.MWarehouse;
|
||||||
|
@ -41,35 +41,22 @@ import org.compiere.util.Msg;
|
||||||
public class BPartnerOrgLink extends SvrProcess
|
public class BPartnerOrgLink extends SvrProcess
|
||||||
{
|
{
|
||||||
/** Existing Org */
|
/** Existing Org */
|
||||||
|
@Parameter
|
||||||
private int p_AD_Org_ID;
|
private int p_AD_Org_ID;
|
||||||
/** Info for New Org */
|
/** Info for New Org */
|
||||||
|
@Parameter
|
||||||
private int p_AD_OrgType_ID;
|
private int p_AD_OrgType_ID;
|
||||||
|
/** Role */
|
||||||
|
@Parameter
|
||||||
|
private int p_AD_Role_ID;
|
||||||
/** Business Partner */
|
/** Business Partner */
|
||||||
private int p_C_BPartner_ID;
|
private int p_C_BPartner_ID;
|
||||||
/** Role */
|
|
||||||
private int p_AD_Role_ID;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare - e.g., get Parameters.
|
* Prepare - e.g., get Parameters.
|
||||||
*/
|
*/
|
||||||
protected void prepare()
|
protected void prepare(){
|
||||||
{
|
|
||||||
ProcessInfoParameter[] para = getParameter();
|
|
||||||
for (int i = 0; i < para.length; i++)
|
|
||||||
{
|
|
||||||
String name = para[i].getParameterName();
|
|
||||||
if (para[i].getParameter() == null)
|
|
||||||
;
|
|
||||||
else if (name.equals("AD_Org_ID"))
|
|
||||||
p_AD_Org_ID = para[i].getParameterAsInt();
|
|
||||||
else if (name.equals("AD_OrgType_ID"))
|
|
||||||
p_AD_OrgType_ID = para[i].getParameterAsInt();
|
|
||||||
else if (name.equals("AD_Role_ID"))
|
|
||||||
p_AD_Role_ID = para[i].getParameterAsInt();
|
|
||||||
else
|
|
||||||
MProcessPara.validateUnknownParameter(getProcessInfo().getAD_Process_ID(), para[i]);
|
|
||||||
}
|
|
||||||
p_C_BPartner_ID = getRecord_ID();
|
p_C_BPartner_ID = getRecord_ID();
|
||||||
} // prepare
|
} // prepare
|
||||||
|
|
||||||
|
@ -92,11 +79,11 @@ public class BPartnerOrgLink extends SvrProcess
|
||||||
// BP Location
|
// BP Location
|
||||||
MBPartnerLocation[] locs = bp.getLocations(false);
|
MBPartnerLocation[] locs = bp.getLocations(false);
|
||||||
if (locs == null || locs.length == 0)
|
if (locs == null || locs.length == 0)
|
||||||
throw new IllegalArgumentException ("Business Partner has no Location");
|
throw new IllegalArgumentException (Msg.getMsg(getCtx(),"BPartnerHasNoLocation"));
|
||||||
// Location
|
// Location
|
||||||
int C_Location_ID = locs[0].getC_Location_ID();
|
int C_Location_ID = locs[0].getC_Location_ID();
|
||||||
if (C_Location_ID == 0)
|
if (C_Location_ID == 0)
|
||||||
throw new IllegalArgumentException ("Business Partner Location has no Address");
|
throw new IllegalArgumentException (Msg.getMsg(getCtx(),"BPartnerLocationHasNoAddress"));
|
||||||
|
|
||||||
// Create Org
|
// Create Org
|
||||||
boolean newOrg = p_AD_Org_ID == 0;
|
boolean newOrg = p_AD_Org_ID == 0;
|
||||||
|
@ -107,14 +94,15 @@ public class BPartnerOrgLink extends SvrProcess
|
||||||
org.setName (bp.getName());
|
org.setName (bp.getName());
|
||||||
org.setDescription (bp.getDescription());
|
org.setDescription (bp.getDescription());
|
||||||
if (!org.save())
|
if (!org.save())
|
||||||
throw new Exception ("Organization not saved");
|
throw new Exception (Msg.getMsg(getCtx(),"OrganizationNotSaved"));
|
||||||
}
|
}
|
||||||
else // check if linked to already
|
else // check if linked to already
|
||||||
{
|
{
|
||||||
int C_BPartner_ID = org.getLinkedC_BPartner_ID(get_TrxName());
|
int C_BPartner_ID = org.getLinkedC_BPartner_ID(get_TrxName());
|
||||||
if (C_BPartner_ID > 0)
|
if (C_BPartner_ID > 0) {
|
||||||
throw new IllegalArgumentException ("Organization '" + org.getName()
|
MBPartner partner = new MBPartner (getCtx(), C_BPartner_ID, get_TrxName());
|
||||||
+ "' already linked (to C_BPartner_ID=" + C_BPartner_ID + ")");
|
throw new IllegalArgumentException (Msg.getMsg(getCtx(),"OrganizationAlreadyLinkedBusinessPartner",new Object[] {org.getName(), partner.getName()} ));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
p_AD_Org_ID = org.getAD_Org_ID();
|
p_AD_Org_ID = org.getAD_Org_ID();
|
||||||
|
|
||||||
|
@ -137,7 +125,7 @@ public class BPartnerOrgLink extends SvrProcess
|
||||||
{
|
{
|
||||||
wh = new MWarehouse(org);
|
wh = new MWarehouse(org);
|
||||||
if (!wh.save(get_TrxName()))
|
if (!wh.save(get_TrxName()))
|
||||||
throw new Exception ("Warehouse not saved");
|
throw new Exception (Msg.getMsg(getCtx(),"WarehouseNotSaved"));
|
||||||
}
|
}
|
||||||
// Create Locator
|
// Create Locator
|
||||||
MLocator mLoc = wh.getDefaultLocator();
|
MLocator mLoc = wh.getDefaultLocator();
|
||||||
|
@ -151,7 +139,7 @@ public class BPartnerOrgLink extends SvrProcess
|
||||||
// Update/Save Org Info
|
// Update/Save Org Info
|
||||||
oInfo.setM_Warehouse_ID(wh.getM_Warehouse_ID());
|
oInfo.setM_Warehouse_ID(wh.getM_Warehouse_ID());
|
||||||
if (!oInfo.save(get_TrxName()))
|
if (!oInfo.save(get_TrxName()))
|
||||||
throw new Exception ("Organization Info not saved");
|
throw new Exception (Msg.getMsg(getCtx(),"OrganizationInfoNotSaved"));
|
||||||
|
|
||||||
// Update BPartner
|
// Update BPartner
|
||||||
bp.setAD_OrgBP_ID(p_AD_Org_ID);
|
bp.setAD_OrgBP_ID(p_AD_Org_ID);
|
||||||
|
@ -160,7 +148,7 @@ public class BPartnerOrgLink extends SvrProcess
|
||||||
|
|
||||||
// Save BP
|
// Save BP
|
||||||
if (!bp.save())
|
if (!bp.save())
|
||||||
throw new Exception ("Business Partner not updated");
|
throw new Exception (Msg.getMsg(getCtx(),"BPartnerNotUpdated"));
|
||||||
|
|
||||||
// Limit to specific Role
|
// Limit to specific Role
|
||||||
if (p_AD_Role_ID != 0)
|
if (p_AD_Role_ID != 0)
|
||||||
|
@ -186,7 +174,7 @@ public class BPartnerOrgLink extends SvrProcess
|
||||||
// Reset Client Role
|
// Reset Client Role
|
||||||
MRole.getDefault(getCtx(), true);
|
MRole.getDefault(getCtx(), true);
|
||||||
|
|
||||||
return "Business Partner - Organization Link created";
|
return Msg.getMsg(getCtx(),"BPartnerOrganizationLinkCreated");
|
||||||
} // doIt
|
} // doIt
|
||||||
|
|
||||||
} // BPartnerOrgLink
|
} // BPartnerOrgLink
|
||||||
|
|
Loading…
Reference in New Issue