PO Wrapper
From iDempiere en
THIS POWRAPPER WAS TAUGHT TO ME BY HENGSIN AND I HAVE REDUCED IT TO A MINIMAL STYLE FOR OTHERS TO FOLLOW - Red1 (talk)
Introduction
- POWrapper is used when we modify any core model, though not recommended in Red1 (talk) best practice, it can still be used when it is absolutely necessary.
Preparation
- Firstly you have a new field lets say in C_Order, which is Vehicle_ID.
- So after creating this field in the AD, you generate model for the X_ and I_ classes.
Plugin Placing
- You place the I_C_Order class in your plugin
- You make a new MOrder extends org.compiere.model.MOrder
Wrapper Method
- Inside the plugin MOrder, you just put in this snippet:
public I_C_Order getWrapper(){
return POWrapper.create(this, I_C_Order.class);
}
Calling Class
- In any class such as an EventValidator or another class, the new field is called for example in this test:
MOrder order = new MOrder(Env.getCtx(),0,null);
order.getWrapper().setVehicle_ID(1000000);
order.setDescription("POWrapper mumbo - "+order.getWrapper().getVehicle_ID());
Result
- SUCCESS! It works as shown here. The DB also has the new value in it.

