title: OperationalError: stack depth limit exceeded
body: <p>Working with openerp 6.1, I want to make a trigger to create two phone calls with dates different from the date in the inserted row (one after 6 months and one after one year).</p>
  
  <p>I created this function:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION create_first_phonecall()
    RETURNS trigger AS
  $BODY$
  BEGIN
  select * from crm_phonecall where id= (select max(id) from crm_phonecall);
     insert into crm_phonecall (name,date,state,active,user_id,x_contractnumber,x_instdate)
  values('Hany', CURRENT_TIMESTAMP,'open',true,16,123456789999,CURRENT_TIMESTAMP);
  return null;
  END;
  $BODY$
    LANGUAGE 'plpgsql'
  </code></pre>
  
  <p>Then I created the following trigger:</p>
  
  <pre><code>CREATE TRIGGER create_first_phonecall
      AFTER insert ON crm_phonecall
      EXECUTE PROCEDURE create_first_phonecall();
  </code></pre>
  
  <p>But when i try to insert a phone call i get the following error:</p>
  
  <pre><code>Client Traceback (most recent call last):
    File "C:\Program Files (x86)\OpenERP\Server\server\openerp\addons\web\common\http.py", line 180, in dispatch
    File "C:\Program Files (x86)\OpenERP\Server\server\openerp\addons\web\controllers\main.py", line 970, in create
    File "C:\Program Files (x86)\OpenERP\Server\server\openerp\addons\web\common\openerplib\main.py", line 250, in proxy
    File "C:\Program Files (x86)\OpenERP\Server\server\openerp\addons\web\common\openerplib\main.py", line 117, in proxy
    File "C:\Program Files (x86)\OpenERP\Server\server\openerp\addons\web\common\http.py", line 608, in send
  
  
  Server Traceback (most recent call last):
    File "C:\Program Files (x86)\OpenERP\Server\server\openerp\addons\web\common\http.py", line 593, in send
    File "C:\Program Files (x86)\OpenERP\Server\server\.\openerp\netsvc.py", line 360, in dispatch_rpc
    File "C:\Program Files (x86)\OpenERP\Server\server\.\openerp\service\web_services.py", line 586, in dispatch
    File "C:\Program Files (x86)\OpenERP\Server\server\.\openerp\osv\osv.py", line 167, in execute_kw
    File "C:\Program Files (x86)\OpenERP\Server\server\.\openerp\osv\osv.py", line 121, in wrapper
    File "C:\Program Files (x86)\OpenERP\Server\server\.\openerp\osv\osv.py", line 176, in execute
    File "C:\Program Files (x86)\OpenERP\Server\server\.\openerp\osv\osv.py", line 164, in execute_cr
    File "C:\Program Files (x86)\OpenERP\Server\server\.\openerp\osv\orm.py", line 4194, in create
    File "C:\Program Files (x86)\OpenERP\Server\server\.\openerp\sql_db.py", line 152, in wrapper
    File "C:\Program Files (x86)\OpenERP\Server\server\.\openerp\sql_db.py", line 212, in execute
  OperationalError: stack depth limit exceeded
  HINT:  Increase the configuration parameter "max_stack_depth", after ensuring the platform's stack depth limit is adequate.
  CONTEXT:  SQL statement "SELECT 1 FROM ONLY "public"."res_users" x WHERE "id" OPERATOR(pg_catalog.=) $1 FOR SHARE OF x"
  SQL statement "INSERT INTO crm_phonecall (name,date,state,active,user_id,x_contractnumber,x_instdate) values('Hany', CURRENT_TIMESTAMP,'open',true,16,123456789999,CURRENT_TIMESTAMP)"
  PL/pgSQL function "create_first_phonecall" line 3 at SQL statement
  SQL statement "INSERT INTO crm_phonecall (name,date,state,active,user_id,x_contractnumber,x_instdate) values('Hany', CURRENT_TIMESTAMP,'open',true,16,123456789999,CURRENT_TIMESTAMP)"
  PL/pgSQL function "create_first_phonecall" line 3 at SQL statement
  SQL statement "INSERT INTO crm_phonecall (name,date,state,active,user_id,x_contractnumber,x_instdate) values('Hany', CURRENT_TIMESTAMP,'open',true,16,123456789999,CURRENT_TIMESTAMP)"
  ...
  </code></pre>
  
  <p>(Many more of the same message from Postgres.)</p>
  
  <p>Can anyone help me with that?</p>