This HowTo require a safe handling of PHP language, because you need to customize the settings in code.
Also you must understand, how our EventHandler module works and you need to install this module before you start.

This howto handle the following problem:
You have a field “Purchasing price” in Products module and wants to automatically load the price from this field, instead the default unit price, if you create a PurchaseOrder or another custom Inventory module.

To solve this, we define 3 Events. If you have installed Colorizer with File modifications, you only needs to add 2 new Events into vTiger Source.

At first create an EventHandler, like I describe in EventHandler Description. You need this file to do the custom assignments.

Let us start with implementation of the events within vTiger CRM code.

File: layouts/vlayout/modules/Inventory/resources/Edit.js ~Line 1712


var dataUrl = "index.php?module=Inventory&action=GetTaxes&record=""&currency_id="+jQuery('#currency_id option:selected').val();

Replace with:

var dataUrl = "index.php?module=Inventory&action=GetTaxes&record=""&currency_id="+jQuery('#currency_id option:selected').val()+"&src_module=" + jQuery('#module').val();

File: modules/Products/models/Record.php ~Line 17


return 'index.php?module=Inventory&action=GetTaxes&record='. $this->getId();

Insert before:

return EventHandler_Module_Model::do_filter('vtiger.filter.product.gettaxesurl', 'index.php?module=Inventory&action=GetTaxes&record='. $this->getId(), $this);

File: modules/Inventory/actions/GetTaxes.php ~Line 36


	$recordId => array(
		'id'=>$recordId, 'name'=>decode_html($recordModel->getName()),
		'taxes'=>$taxes, 'listprice'=>$listPrice, 'listpricevalues'=>$listPriceValues,
		'description' => decode_html($recordModel->get('description')),
		'quantityInStock' => $recordModel->get('qtyinstock')


Replace with:

                  $recordId => array(
                     'id'=>$recordId, 'name'=>decode_html($recordModel->getName()),
                     'taxes'=>$taxes, 'listprice'=>$listPrice, 'listpricevalues'=>$listPriceValues,
                     'description' => decode_html($recordModel->get('description')),
                     'quantityInStock' => $recordModel->get('qtyinstock')
                  )), $recordModel));


The next one only needs to be done, if you do NOT have the Colorizer installed.
You could check this, if you search for vtiger.filter.listview.querygenerator.query in the following file. If you found something, do NOT add a second one.
Also maybe Colorizer ask to delete your manually added filter, if you install this module later. Because it is the same filter, it is not a problem to remove and let Colorizer add automatically.

File: modules/Products/models/ListView.php ~Line 118 

Search: (You will found two matches within the file. Choose the one in function getListViewEntries)

$listQuery = $this->getQuery();

Insert After:


$listQuery = EventHandler_Module_Model::do_filter("vtiger.filter.listview.querygenerator.query", $listQuery, $this->get('query_generator'));

This was all within vTigerCRM source.

Now you need to attach your created EventHandler to these 3 Events:


If you already use the handleFilter function for other filters, please filter the information you need from the next source. If you do not have a handleFilter function in your class, you could use this one:

[prism field=handler language=php]

In this example, the custom field with the price is cf_852. You MUST change this.
Also if you want to change the module, which will trigger this field, change “PurchaseOrder” to another module. It will works for every Inventory module.

Like you recognize, it only does something if the module is correct. So you shouldn’t get problems in other modules. But like any modification: Test all possible situations to be sure, it works.