Skip to Content
Menu
This question has been flagged
3 Replies
3322 Views

One many2one field in crm_lead and sale_order is corresponding to res_user ids.

When I am selecting one id in res_users where id=52 (related partner present in res.partner where id=43171), it is not getting saved either in lead/opportunity or sales order. But it accepts for other res_user ids in either objects.

When I try to update it using SQL query, either in crm.lead or sale.order it shows error :

ERROR:  insert or update on table "crm_lead" violates foreign key constraint "crm_lead_rep_fkey"

DETAIL:  Key (rep)=(52) is not present in table "res_partner".

********** Error **********


ERROR: insert or update on table "crm_lead" violates foreign key constraint "crm_lead_rep_fkey"

SQL state: 23503

Detail: Key (rep)=(52) is not present in table "res_partner".

When I check the res_partner table, id=52 is not present. But as per query I don't understand the relation with res_partner table, instead the related partner id of Rahul in res.partner is  43171.

Everything remaining same in testing instance, write function is working. (There also id=52 is not present in res_partner, but the record is getting saved here).

So l am confused why write is not happening only in live server and that too for res_user id=52 which has got no relation with res_partner table id=52.

Can anyone help in this ?


Regards

Sumit Sinha

Avatar
Discard

which field is actually you are trying to update?

Author Best Answer

Hi Hilar,

I am trying to update a field present in sale.order and crm.lead and it takes res_user ids. In my case, it is not taking for id=52, but other id it is taking.


Hi Mitul,

When I am not considering res_partner table in that field, why is that id checked into that table. It is of course present in res_user table and my field also correspond to same table.

And how can I save that id=52 in my crm_lead/sale_order.


Regards

Sumit Sinha

Avatar
Discard
Best Answer

hello

the problem is the reference for the partner table field is not proper set into the field.

for eg. here you get an error like Key (rep)=(52) is not present in table "res_partner". so it means 52 number id is not present into the table res_partner. and when you write into the field of crm_lead/sale_order table's partner field at that time the id which is you set that is from some another tables not from the res_partner. that's why you get this error. 

Avatar
Discard
Related Posts Replies Views Activity
1
Nov 20
5907
2
Jul 24
426
2
May 24
391
1
Feb 24
320
1
Mar 23
1253