The goal of this post is to show how it is easy to integrate Openbravo ERP and Groovy. Openbravo ERP is the world leader of open source ERPs. It is Java based and it is built on several standards such as Java Servlet, XML, JSON and Hibernate. Groovy is a programming languge belonging to the world of JVM languages. It can be compiled in order to share its byte code with other JVM languages but it can be also used such as a scripting language; in other words you can use it with no compilation steps, just loading a piece of code into a Java class and execute it. If you are a Java developer you can begin using Java code and almost in the 100% of cases your Groovy code will work. Now it’s time to begin, let’s go to use this Openbravo module.
Installing Groovy Adapter module
There are two ways in order to install the Groovy Adapter module: downloading the obx file from the Openbravo Forge site or installing it using the Module Management menu of Openbravo ERP with System administrator role. In the first case you have to point your browser to Groovy Adapter module and download the last version of the module (now at 0.0.3).
Once you have downloaded the obx file, you can access to Openbravo with System Administrator role and choose the Module Management menu item.
Select the the Add Module tab and through the Browse File System button load the obx file you had downloaded from the openbravo forge site.
The second way is more easy you need just to search the module on the Add Module tab of Module Management Window, select the Groovy Adapter module and finish the installation process.
If you have installed the module, after restarting the Openbravo ERP you can access to the ERP with System Administrator role then you can begin to play with Groovy. Choose the Groovy console window and it will show this UI
How you can see there is the Source text area where you can write and store the Groovy code, on the top right side there is an Excute Groovy button. If you push on it the Groovy code will be executed and the output will be shown on the Output text area. If something goes wrong an error will apeear in the status bar message box, instead if all things work fine the computation time will be shown. The name field is mandatory and must be unique, at the moment we don’t talk about how we can use this field but we’ll do for sure in the next post.
First conclusions and next steps
Ok, I hope this post is enough for the moment, through this reading you are able to load the module and to begin to play with simple Groovy scripts. Pay attention to its usage, this module can be used ONLY with System Administrator role because it may be very dangerous, if you delete something through a script, that data will be losed forever. I’ve in mind to write other posts and to improve the module allowing its usage to cover several Openbravo development patterns (Java Process, callouts and so on …).