xTuple.com xTupleU Blog & News Customer Support

Creating Opportunity - insert or update on table "ophead" violates foreign key constraint

Hello, I cannot create an opportunity for some reason. I get the following error:

ERROR:  insert or update on table "ophead" violates foreign key constraint "ophead_ophead_opsource_id_fkey"
DETAIL:  Key (ophead_opsource_id)=(-1) is not present in table "opsource".
(23503) QPSQL: Unable to create query
 
The Query:
INSERT INTO ophead      (ophead_id, ophead_name, ophead_crmacct_id,       ophead_owner_username,       ophead_opstage_id, ophead_opsource_id,       ophead_optype_id, ophead_probability_prcnt,       ophead_amount, ophead_curr_id, ophead_target_date,       ophead_actual_date,       ophead_notes, ophead_active, ophead_cntct_id,        ophead_username, ophead_start_date, ophead_assigned_date,        ophead_priority_id, ophead_number) VALUES(:ophead_id, :ophead_name, :ophead_crmacct_id,       :ophead_owner_username,       :ophead_opstage_id, :ophead_opsource_id,       :ophead_optype_id, :ophead_probability_prcnt,       :ophead_amount, :ophead_curr_id, :ophead_target_date,       :ophead_actual_date,       :ophead_notes, :ophead_active, :ophead_cntct_id,        :ophead_username, :ophead_start_date, :ophead_assigned_date,        :ophead_priority_id, :ophead_number);

Running xTuple client: 4.11.2-gccdd8dff4ite
Ran from the backup file: manufacturing_quickstart-4.11.2.backup

Make sure you have opportunity types created

Looks like that was it. Thanks!