Morder- I want to change a method of MOrder- I wanted to redo the same method in a new class and at runtime I want you to read only this method in my new class

122 views
Skip to first unread message

Jorge Babo

unread,
Oct 24, 2019, 3:53:22 PM10/24/19
to iDempiere
Hi
I want to change a method of MOrder. Only I don't want to mess with this class. I wanted to redo the same method in a new class and at runtime I want you to read only this method in my new class.
The goal is to make my method without changing the worldwide programming of idempiere

Ricardo Alexsander Santana

unread,
Oct 24, 2019, 4:21:42 PM10/24/19
to idem...@googlegroups.com
Hi Jorge,

You should create your blank model and extends it to org.compiere.model.MOrder, override the methods you need, then create a Model Factory. An example can be found here:


Regards,
--
Ricardo Alexsander Santana
ralex...@gmail.com


--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/2d80d889-f1f9-44b3-9d07-93d6b35631af%40googlegroups.com.

entregpag Serv

unread,
Oct 24, 2019, 8:57:08 PM10/24/19
to idem...@googlegroups.com
thank you . I will try tomorrow.



--
Abraços
Jorge Babo
ENTREGPAG
Tel: (24)2443-2304 / (24)2443-1339














Andreas Sumerauer

unread,
Oct 30, 2019, 10:00:17 AM10/30/19
to iDempiere
Hello Ricardo,

This looks very promising and I am trying to use that scheme in my own plugin. I have one problem though:
When an order is created by a process (e.g. Create Sales Orders from Expense) it will be created as an MOrder object and not as one of the customized derived class.
To me it looks like the derived class methods will initially not be executed for the orders that are created this way. Only when the Order is recreated using the plugins factory method the customizations should come into effect.
Is there a convenient way to solve this problem? Or is it a problem at all? I am not familiar enough with the inner workings of iDempiere to see wether there are any inbuilt provisions to deal with that case.
Thank You very much !

Andreas 


Am Donnerstag, 24. Oktober 2019 22:21:42 UTC+2 schrieb Ricardo Alexsander Santana:
Hi Jorge,

You should create your blank model and extends it to org.compiere.model.MOrder, override the methods you need, then create a Model Factory. An example can be found here:


Regards,
--
Ricardo Alexsander Santana
ralex...@gmail.com


Em qui, 24 de out de 2019 às 16:53, Jorge Babo <jab...@gmail.com> escreveu:
Hi
I want to change a method of MOrder. Only I don't want to mess with this class. I wanted to redo the same method in a new class and at runtime I want you to read only this method in my new class.
The goal is to make my method without changing the worldwide programming of idempiere

--
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 idem...@googlegroups.com.

Ricardo Alexsander Santana

unread,
Oct 31, 2019, 6:34:11 PM10/31/19
to idem...@googlegroups.com
Hi Andreas,

You are correct. A process such as Create Sales Orders from Expense cannot use your modified MOrder, because the class is called directly from the code (does not pass through ModelFactory). Depending on what you are doing, this may not be a problem, but if you want this process to call your modified MOrder you have to do same procedure to the process, create a copy of your desired process, change the MOrder to your modified version and then create a Process Factory to use your modified process.

--
Ricardo Alexsander Santana
ralex...@gmail.com

To unsubscribe from this group and stop receiving emails from it, send an email to idempiere+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/idempiere/d7e20721-c2de-41ee-9805-e3b3936a6c80%40googlegroups.com.

Andreas Sumerauer

unread,
Nov 4, 2019, 4:26:09 AM11/4/19
to iDempiere
Thanks Ricardo for the confirmation,

I have now resorted to using a helper class with all static methods to implement my plugins business logic.
class myBusinessLogic {
 
public static SomeClass myFunc(MOrder order, SomeOtherClass param,  ...) {
   
// do stuff (...)
   
return result;  
 
}


 
// some more functions go here (...)
}

This approach involves a bit of overhead but I still prefer it because it does not interfere too much with the existing framework.
Also I hope I won't have to worry too much about potential problems when using other third party plugins side by side with mine.

I bumped against quite a number of walls developing that approach and hope I am not doing things in a too strange way. After all I am still not so familiar with the ins and outs of the plugin development API.

Andreas

entregpag Serv

unread,
Dec 20, 2019, 12:52:16 PM12/20/19
to idem...@googlegroups.com
Ricardo, como você está?
Não consigo abrir esse link.

Reply all
Reply to author
Forward
0 new messages