node_presave doesn't work I'm trying to do something before my invoice saves. In my invoice module I have:

function invoice_node_presave($node) {
  var_dump($node); die;
  if ($node-&gt;type == 'invoice') {
    // If true we are creating a new invoice
    if (intval($node-&gt;invoice_number) == 0) {
      // Get new invoice number
      if (intval($node-&gt;user_defined_invoice_number) &gt; 0) {
        $node-&gt;invoice_number = $node-&gt;user_defined_invoice_number;
      }
      else {
        $node-&gt;invoice_number = _invoice_get_new_invoice_number();
      }
    }
  }
  ......
}


As you see I have a var_dump($node) &amp; a die; . This works perfect. But then when I want to add the following in my template.php :

function xmed_node_presave($node){
  dump($node); die;
  if (($node-&gt;type == 'invoice')) { //node has not been saved
      dpr($node); die;
  }


}

He doesn't die. He just runs... Also the rest of functions in my template.php like function xmed_preprocess_page(&amp;$vars) work.
hook_node_presave() is only invoked for modules, so you can't implement it in a theme. 

It'll need to go in a custom module instead.

From a best practice point of view, that sort of logic definitely shouldn't be at the theme layer, it should be in a module.