Book Image

ADempiere 3.6 Cookbook

Book Image

ADempiere 3.6 Cookbook

Overview of this book

Table of Contents (16 chapters)
ADempiere 3.6 Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface

Modifying hooks for a model


Every model extends the PO class, which provides various hooks (methods) that one can override. They are afterSave, beforeSave, afterDelete, and beforeDelete. The syntax for these methods are:

protected boolean afterSave(boolean newRecord, boolean success) protected boolean afterDelete(boolean success) protected boolean beforeSave (boolean newRecord) protected boolean beforeDelete()

The main use of these methods is to perform additional tasks while a particular row of a table is being saved or deleted a particular row of a table. Let us say, we want to audit the activity, like create/update and delete, of the C_Project table. To accomplish this, we shall override the beforeSave and beforeDelete methods so that the audit information can be captured before the actual project information is updated or deleted.

In this recipe, we'll see how to override these hooks.

How to do it...

  1. 1. Implement the afterSave method in the Mmom model class to send the e-mail to the participants...