Others

Creating Virtual Fields Using Property Fields in the Openbravo ERP Platform

In our previous blog post, we looked at how to create virtual columns using Client Class. In this one, we will see how to create virtual columns using property fields. The basic difference between a client class and property field is that client class is more suitable for UX enhancement or styling, whereas property fields are those fields whose values are derived from existing fields in the records. In the below example, we will see a scenario where this might be useful.

Note: The examples provided below are available as a module here.

Use case 1

In the Product window, there is a tab called Price, where the price list version, the unit price and the list price are listed.

Creating Virtual - Image1

But in a multicurrency environment, unless we navigate to the price list version and check the price list parent tab, we cannot know for which currency the prices are listed. To fix this, let’s add the currency property field to the Price tab.

Creating Virtual - Image2

Here the value of the property field is priceListVersion.priceList.currency. The price list version is already available in the window and we are using this information to navigate to its parent tab Price List and fetch the value of the currency field present in it. Once we compile and restart the tomcat server, here’s what the Price tab will look like.

Creating Virtual - Image3

Use case 2

The warehouse admin is cross-verifying the Goods Receipt and the actual goods that have been received and notices a discrepancy. Admin decides to call the supplier to inform them about this. The Goods Receipt window has the Partner name and the Partner Address.

Creating Virtual - Image4

If we click on the Partner Address tab, we can notice the phone number of the Supplier.

Creating Virtual - Image5

Imagine this action has to be performed quite frequently to get any information or even for a simple confirmation. So let’s speed up this process by adding the Supplier Phone number as a property field in the Goods Receipt window.

Creating Virtual - Image6

The definition of the property field is pretty simple as we are just fetching the phone number field corresponding to the partner address. Here is what the output will look like.

Creating Virtual - Image7

In general, property fields are more suitable in scenarios where you are going to display more than one field from a referenced entity. Instead of adding new fields for each required field in the database and setting the value from the other entity, we can just add one field and use it as a reference for the other fields.

Did you find useful this information? Do you have any doubts when creating them? Just let me know in the comments section :)

Previous post

How to locate a performance problem with AppDynamics

Next post

Creating virtual fields using computed columns in the Openbravo ERP Platform

No Comment

Leave a reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>