Best way to store the ad_client_id using the Idempiere API and PO Object...

171 views
Skip to first unread message

Pedro Rozo

unread,
Aug 17, 2013, 12:01:06 PM8/17/13
to idem...@googlegroups.com
Hi everyone ..

We are almost finishing our SmartPOS migration, and we faced some minor issues because the PO methods are not consistent for all the children classes that extend the PO object) ...

We just want to update the ad_client_id on orders, rma and so on ... for that purpose we found the setClientOrg(client, org) which sounded the best, but it is available just for some objects like order, invoice and other,, and it is not available on these classes so far:

MInOut
MInvoiceLine
MOrderLine
MRMA
MRMALine
MPayment
MAllocationHdr
MAllocationLine
MBPartnerLocation
MUser
MLocation
MLocation

Then instead of use that we are trying to use this approach, PO.set_ValueOfColumn("ad_client_id",value);

but we are not sure if it is the best to keep all the PO updates for this ad_client_id any suggestions. Perhaps it would be better to have a method like this in the PO claasses to be extended for all the chidren.

Regards,

Pedro Rozo

Carlos Antonio Ruiz Gomez

unread,
Aug 20, 2013, 8:04:13 PM8/20/13
to idem...@googlegroups.com
Is code published?

Pedro Rozo

unread,
Aug 21, 2013, 10:52:51 PM8/21/13
to idem...@googlegroups.com
Sure Carlos here you can see one of the java files using different approach for the same goal which is to set a client id in many ERP docs using the APO (not available same method for the same purpose in the PO children as mentioned before ) we would appreciate your suggestions to have a consistent approach and apply best practices,



693    order exampl setting ad_client_id using
order.setClientOrg(dataLogin.get("ad_client_id"), dataLogin.get("ad_org_id"));


758   orderline: example  setting ad_client_id but using differente method .. setclientOrg not available
 line.set_ValueOfColumn("ad_client_id",dataLogin.get("ad_client_id") );  


Regards

Pedro Rozo

Carlos Antonio Ruiz Gomez

unread,
Aug 22, 2013, 9:54:39 AM8/22/13
to idem...@googlegroups.com
Thanks Pedro for publishing FOSS.

I think you must not set ad_client_id, that must be taken automatically from context, if the record is being saved in wrong client it can be a context problem.

Forcing the ad_client_id can lead to other problems, for example the order saved in gardenworld and the changelog saved in system (or the client on ctx).

Regards,

Carlos Ruiz

Pedro Rozo

unread,
Aug 22, 2013, 10:12:37 AM8/22/13
to idem...@googlegroups.com
Carlos

For our case.. our SmartPOS listener (It is OSGi plugin that does not have context information because is running in background as independent thread (activator) ( any time that a new XML messages comes in real time from RabbitMQ (ismilar to JMS), it tries to create the ERP documents ... but each XML message includes the org id and client is where should be inserted .. that is why we need to specify the client id at that moment ...   

It is not an scenario where a user is logged in .. is a 100% background process to synchorinize (bydirectional) in real time Idempiere with the remote SmartPOS  (using the high performance AMQP protocol and RabbitMQ) hope that help to clarify ... that is common integration scenario where we need to insert manually the ad:client:id   and not get it from the context  I guess---

Regards-

Pedro Rozo

Carlos Antonio Ruiz Gomez

unread,
Aug 22, 2013, 10:19:54 AM8/22/13
to idem...@googlegroups.com
Context is needed, indeed you're creating the context (i.e. line 72)


On 22/08/13 09:12, Pedro Rozo wroet:

Pedro Rozo

unread,
Aug 22, 2013, 10:27:11 AM8/22/13
to idem...@googlegroups.com
If tht is the case, and I understand your point I should create (init) a new context with that clientId/irgid information coming from my xml messages and managed from my external OSGi plugin (thread) before these transactions ... so when I try to create for example an order, the API will get that client  info from the idempiere context .. is that correct ?

Regards

Pedro R

Heng Sin Low

unread,
Aug 22, 2013, 10:46:51 AM8/22/13
to idem...@googlegroups.com
Hi Pedro,

Yes, you should create new context ( ServerContext.setCurrentInstance ) for each integration request and you have to dispose ( ServerContext.dispose ) it after completion of the request.

It is consider dangerous to do your background job without the correct context being setup first.

Regards,
Low


--
You received this message because you are subscribed to the Google Groups "iDempiere" group.
To unsubscribe from this group and stop receiving emails from it, send an email to idempiere+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages