Not Possible to Link Business Partner to an Organization

Description

When trying to Link a Business Partner to an Organization I get the following error message: “Business Partner not updated” and when looking in the log iDempiere has thrown an exception!

------------------------------- 12:13:55.690===========> DB.saveError: DBExecuteError - ERROR: column "ad_orgbp_id" is of type numeric but expression is of type character varying
Hint: You will need to rewrite or cast the expression.
Position: 35 [74]
------------------------------- 12:13:55.691-----------> MBPartner.doUpdate: #-1 - [SvrProcess_a12b86d2-9f02-4321-a058-8a4a31ecb740] - C_BPartner.C_BPartner_ID=1000000 [74]
12:13:55.696===========> BPartnerOrgLink.process: Business Partner not updated [74]
java.lang.Exception: Business Partner not updated
at org.compiere.process.BPartnerOrgLink.doIt(BPartnerOrgLink.java:160)
at org.compiere.process.SvrProcess.process(SvrProcess.java:176)
at org.compiere.process.SvrProcess.startProcess(SvrProcess.java:122)
at org.adempiere.util.ProcessUtil.startJavaProcess(ProcessUtil.java:172)
at org.compiere.apps.AbstractProcessCtl.startProcess(AbstractProcessCtl.java:466)
at org.compiere.apps.AbstractProcessCtl.run(AbstractProcessCtl.java:234)
at org.adempiere.webui.apps.WProcessCtl.process(WProcessCtl.java:158)
at org.adempiere.webui.apps.ProcessModalDialog$ProcessDialogRunnable.doRun(ProcessModalDialog.java:513)
at org.adempiere.util.ContextRunnable.run(ContextRunnable.java:38)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)

Environment

demo.idempiere.com

Activity

Show:
Anthony Sossah
May 3, 2013, 4:00 PM

Hi,
I checked this out. This is happening because AD_orgbp_ID in C_BPartner is being used as a button whilst at the same time it is used to store the linked org ID. So we have a DB type int but an AD display type Button.

In code, this goes to the heart of the PO class during saveupdate(). There are some changes in the PO class in iDempiere that makes this break in iDempiere

protected boolean saveUpdate()
{
boolean ok = doUpdate(isLogSQLScript());

return saveFinish (false, ok);
}
boolean ok = doUpdate(true); will work because it uses the old code block but this is not good because the new code logs migration scripts as per the settings of isLogSQLScript() in ini file.

The new code uses an object values array to set params for the generated sql, this is passing a string and causing the DB to throw error.
A quick fix will be to introduce a new field to take care of button duties in C_BPartner and leave AD_orgbp_ID to store the org link but who knows which other parts are broken because of the PO changes. Else we look at the params array to pass int instead of string. or replace new code block in

else{
}
with old code block in if(withValues){} inside function doUpdate(boolean). This should work

xolali

Carlos Ruiz
May 5, 2013, 4:07 AM

Thanks Flemming for testing and reporting.

Thanks Anthony for the analysis.

I found strange that C_Project.C_ProjectType_ID was working fine - so I implemented the same approach to solve this.

Found that copying a project or a BP with these columns set was failing and fixed with the committed migration script.

Regards,

Carlos Ruiz

Assignee

Carlos Ruiz

Reporter

Flemming Birch

Labels

None

Tested By

None

Components

Affects versions

Priority

Major
Configure