add a second sql order each time you insert and edit records, I've tried the sample code, but only the order, adding runs.
$e["on_insert"] = array("add_client", null, true);
$grid->set_events($e);
function add_client(&$data)
{
$id = intval($_GET["rowid"]);
$data["params"]["IdDiario"] = $id;
$FechaDelMovimiento = date(Y-m-d);
$sql = "INSERT INTO `trazabilidad`
(`IdTraza`, `IdEntrada`, `Idproducto`, `FCaducidad`, `Referencia`, `Cantidad`, `UnidadCaja`, `Total`, `Lote`, `Tipo`, `UBI`, `igic`, `FMOVI`, `Almacen`)
VALUES
(NULL, '{$data["params"]["IdDetalleEntrada"]}', '{$data["params"]["IdProducto"]}', '{$data["params"]["FechaCaducidad"]}', '{$data["params"]["RefProv"]}', '{$data["params"]["Cantidad"]}', '{$data["params"]["UnidadCaja"]}',
'{$data["params"]["Total"]}', '{$data["params"]["Lote"]}', 'E', '{$data["params"]["UBICACION"]}', '{$data["params"]["IGIC"]}', '".$FechaDelMovimiento."', '1')";
mysql_query($sql);
// params are array(<function-name>,<class-object> or <null-if-global-func>,<continue-default-operation>)
// if you pass last argument as true, functions will act as a data filter, and insert/update will be performed by grid
$e["on_insert"] = array("add_client", null, true);
It looks like it is running default insert as well as yours, so making 3rd arg to false should run only your insert.