[FIX] fields: in `one2many.set`, replace incorrect query by ORM access
[FIX] fields: in `one2many.set`, replace incorrect query by ORM access

When linking a record into a `one2many` relation with command `(4, rid)`, a
query checks whether the record is already linked to the current record id:

    SELECT 1 FROM {inv_table} WHERE id={rid} AND {inv_field}={id}

where `inv_field` is the name of the inverse field, and `inv_table` is the
table where this field is stored.

The query is wrong if the inverse field is inherited, because the `rid` does
not belong to the table `inv_table`.

The test has been replaced by a plain ORM access:

    rec = obj.browse(cr, SUPERUSER_ID, rid)
    if int(rec[inv_field]) != id:
        ...

This fixes #4685.

poljeff/odoo,Daniel-CA/odoo,stephen144/odoo,xzYue/odoo,ChanduERP/odoo,bplancher/odoo,Adel-Magebinary/odoo,ygol/odoo,factorlibre/OCB,brijeshkesariya/odoo,gorjuce/odoo,shaufi/odoo,hip-odoo/odoo,Endika/OpenUpgrade,datenbetrieb/odoo,JGarcia-Panach/odoo,jiangzhixiao/odoo,Maspear/odoo,makinacorpus/odoo,chiragjogi/odoo,apanju/GMIO_Odoo,luistorresm/odoo,datenbetrieb/odoo,dsfsdgsbngfggb/odoo,stephen144/odoo,fuhongliang/odoo,VielSoft/odoo,minhtuancn/odoo,rgeleta/odoo,ApuliaSoftware/odoo,rubencabrera/odoo,srimai/odoo,odootr/odoo,BT-ojossen/odoo,rgeleta/odoo,Endika/OpenUpgrade,chiragjogi/odoo,rubencabrera/odoo,sv-dev1/odoo,glovebx/odoo,Bachaco-ve/odoo,RafaelTorrealba/odoo,CatsAndDogsbvba/odoo,hubsaysnuaa/odoo,BT-fgarbely/odoo,mustafat/odoo-1,jiangzhixiao/odoo,luistorresm/odoo,ecosoft-odoo/odoo,dariemp/odoo,datenbetrieb/odoo,Elico-Corp/odoo_OCB,salaria/odoo,fevxie/odoo,storm-computers/odoo,apanju/GMIO_Odoo,dsfsdgsbngfggb/odoo,ehirt/odoo,rowemoore/odoo,markeTIC/OCB,mlaitinen/odoo,Endika/odoo,Daniel-CA/odoo,syci/OCB,brijeshkesariya/odoo,dfang/odoo,fuhongliang/odoo,JGarcia-Panach/odoo,bplancher/odoo,stephen144/odoo,hoatle/odoo,poljeff/odoo,mustafat/odoo-1,tangyiyong/odoo,fjbatresv/odoo,Elico-Corp/odoo_OCB,poljeff/odoo,QianBIG/odoo,lsinfo/odoo,dsfsdgsbngfggb/odoo,tvibliani/odoo,minhtuancn/odoo,BT-fgarbely/odoo,ygol/odoo,windedge/odoo,Antiun/odoo,hoatle/odoo,BT-fgarbely/odoo,dfang/odoo,BT-fgarbely/odoo,storm-computers/odoo,hanicker/odoo,microcom/odoo,fuhongliang/odoo,Antiun/odoo,dariemp/odoo,tangyiyong/odoo,jiangzhixiao/odoo,grap/OpenUpgrade,Noviat/odoo,Elico-Corp/odoo_OCB,synconics/odoo,n0m4dz/odoo,tvibliani/odoo,vnsofthe/odoo,sinbazhou/odoo,synconics/odoo,ShineFan/odoo,makinacorpus/odoo,hanicker/odoo,mszewczy/odoo,Elico-Corp/odoo_OCB,gorjuce/odoo,sysadminmatmoz/OCB,MarcosCommunity/odoo,datenbetrieb/odoo,mszewczy/odoo,bplancher/odoo,avoinsystems/odoo,takis/odoo,nuncjo/odoo,goliveirab/odoo,dalegregory/odoo,hanicker/odoo,rahuldhote/odoo,funkring/fdoo,Noviat/odoo,lgscofield/odoo,rubencabrera/odoo,leorochael/odoo,nuncjo/odoo,vnsofthe/odoo,microcom/odoo,tvibliani/odoo,ShineFan/odoo,jfpla/odoo,KontorConsulting/odoo,laslabs/odoo,syci/OCB,funkring/fdoo,srimai/odoo,goliveirab/odoo,AuyaJackie/odoo,factorlibre/OCB,CatsAndDogsbvba/odoo,chiragjogi/odoo,KontorConsulting/odoo,ShineFan/odoo,salaria/odoo,leorochael/odoo,AuyaJackie/odoo,shingonoide/odoo,Adel-Magebinary/odoo,shingonoide/odoo,OpenUpgrade/OpenUpgrade,MarcosCommunity/odoo,rubencabrera/odoo,Bachaco-ve/odoo,rahuldhote/odoo,optima-ict/odoo,AuyaJackie/odoo,hubsaysnuaa/odoo,hassoon3/odoo,funkring/fdoo,jfpla/odoo,srimai/odoo,nuncjo/odoo,NeovaHealth/odoo,ovnicraft/odoo,ChanduERP/odoo,dalegregory/odoo,avoinsystems/odoo,GauravSahu/odoo,cloud9UG/odoo,GauravSahu/odoo,tinkhaven-organization/odoo,hassoon3/odoo,factorlibre/OCB,mustafat/odoo-1,Antiun/odoo,Nowheresly/odoo,rowemoore/odoo,acshan/odoo,avoinsystems/odoo,Elico-Corp/odoo_OCB,shaufi10/odoo,ecosoft-odoo/odoo,minhtuancn/odoo,tinkhaven-organization/odoo,microcom/odoo,cloud9UG/odoo,lgscofield/odoo,stephen144/odoo,slevenhagen/odoo,Adel-Magebinary/odoo,markeTIC/OCB,markeTIC/OCB,apocalypsebg/odoo,Endika/odoo,ApuliaSoftware/odoo,xzYue/odoo,windedge/odoo,steedos/odoo,bplancher/odoo,x111ong/odoo,sinbazhou/odoo,ApuliaSoftware/odoo,dalegregory/odoo,storm-computers/odoo,minhtuancn/odoo,shaufi10/odoo,factorlibre/OCB,diagramsoftware/odoo,OpenUpgrade/OpenUpgrade,tinkhaven-organization/odoo,kittiu/odoo,takis/odoo,jiangzhixiao/odoo,lsinfo/odoo,glovebx/odoo,rubencabrera/odoo,RafaelTorrealba/odoo,mszewczy/odoo,poljeff/odoo,jfpla/odoo,GauravSahu/odoo,slevenhagen/odoo,luistorresm/odoo,dsfsdgsbngfggb/odoo,rgeleta/odoo,Noviat/odoo,draugiskisprendimai/odoo,provaleks/o8,ovnicraft/odoo,shingonoide/odoo,Maspear/odoo,Endika/OpenUpgrade,acshan/odoo,sinbazhou/odoo,slevenhagen/odoo,salaria/odoo,ShineFan/odoo,fjbatresv/odoo,hip-odoo/odoo,BT-rmartin/odoo,ecosoft-odoo/odoo,acshan/odoo,windedge/odoo,dsfsdgsbngfggb/odoo,Nowheresly/odoo,RafaelTorrealba/odoo,fevxie/odoo,leorochael/odoo,hip-odoo/odoo,avoinsystems/odoo,lgscofield/odoo,provaleks/o8,hip-odoo/odoo,synconics/odoo,avoinsystems/odoo,funkring/fdoo,diagramsoftware/odoo,rahuldhote/odoo,tvibliani/odoo,Daniel-CA/odoo,JGarcia-Panach/odoo,x111ong/odoo,fevxie/odoo,Endika/odoo,cedk/odoo,BT-rmartin/odoo,sergio-incaser/odoo,ygol/odoo,jiangzhixiao/odoo,spadae22/odoo,fuhongliang/odoo,incaser/odoo-odoo,MarcosCommunity/odoo,mszewczy/odoo,NeovaHealth/odoo,luistorresm/odoo,GauravSahu/odoo,shaufi/odoo,OpenUpgrade/OpenUpgrade,lsinfo/odoo,NeovaHealth/odoo,apocalypsebg/odoo,BT-rmartin/odoo,grap/OpenUpgrade,cedk/odoo,spadae22/odoo,laslabs/odoo,hoatle/odoo,ingadhoc/odoo,glovebx/odoo,MarcosCommunity/odoo,Maspear/odoo,BT-rmartin/odoo,diagramsoftware/odoo,ApuliaSoftware/odoo,incaser/odoo-odoo,acshan/odoo,dalegregory/odoo,takis/odoo,rubencabrera/odoo,odootr/odoo,tangyiyong/odoo,optima-ict/odoo,ehirt/odoo,avoinsystems/odoo,QianBIG/odoo,cloud9UG/odoo,alexcuellar/odoo,lgscofield/odoo,diagramsoftware/odoo,shaufi10/odoo,storm-computers/odoo,Endika/odoo,luistorresm/odoo,Noviat/odoo,alexcuellar/odoo,optima-ict/odoo,Endika/OpenUpgrade,alexcuellar/odoo,alexcuellar/odoo,dsfsdgsbngfggb/odoo,RafaelTorrealba/odoo,Nowheresly/odoo,RafaelTorrealba/odoo,mlaitinen/odoo,draugiskisprendimai/odoo,leorochael/odoo,kittiu/odoo,lgscofield/odoo,provaleks/o8,grap/OpenUpgrade,sergio-incaser/odoo,tangyiyong/odoo,QianBIG/odoo,chiragjogi/odoo,srimai/odoo,srimai/odoo,windedge/odoo,n0m4dz/odoo,spadae22/odoo,sinbazhou/odoo,n0m4dz/odoo,NeovaHealth/odoo,datenbetrieb/odoo,ChanduERP/odoo,BT-rmartin/odoo,eino-makitalo/odoo,shingonoide/odoo,ehirt/odoo,laslabs/odoo,tangyiyong/odoo,chiragjogi/odoo,KontorConsulting/odoo,dariemp/odoo,vnsofthe/odoo,apocalypsebg/odoo,QianBIG/odoo,minhtuancn/odoo,shaufi/odoo,ingadhoc/odoo,rgeleta/odoo,xzYue/odoo,shaufi/odoo,sysadminmatmoz/OCB,storm-computers/odoo,hip-odoo/odoo,dariemp/odoo,VielSoft/odoo,sysadminmatmoz/OCB,lsinfo/odoo,hanicker/odoo,alexcuellar/odoo,steedos/odoo,sv-dev1/odoo,ecosoft-odoo/odoo,sergio-incaser/odoo,slevenhagen/odoo,fuhongliang/odoo,CatsAndDogsbvba/odoo,poljeff/odoo,CatsAndDogsbvba/odoo,hanicker/odoo,chiragjogi/odoo,dariemp/odoo,brijeshkesariya/odoo,ChanduERP/odoo,glovebx/odoo,markeTIC/OCB,cedk/odoo,lsinfo/odoo,Nowheresly/odoo,CatsAndDogsbvba/odoo,eino-makitalo/odoo,n0m4dz/odoo,fjbatresv/odoo,apocalypsebg/odoo,x111ong/odoo,markeTIC/OCB,odootr/odoo,gorjuce/odoo,hoatle/odoo,hubsaysnuaa/odoo,Maspear/odoo,kittiu/odoo,Noviat/odoo,hassoon3/odoo,syci/OCB,acshan/odoo,Daniel-CA/odoo,sysadminmatmoz/OCB,dfang/odoo,Adel-Magebinary/odoo,bplancher/odoo,datenbetrieb/odoo,salaria/odoo,rowemoore/odoo,syci/OCB,OpenUpgrade/OpenUpgrade,shingonoide/odoo,ehirt/odoo,syci/OCB,syci/OCB,srimai/odoo,sv-dev1/odoo,Antiun/odoo,ChanduERP/odoo,makinacorpus/odoo,Bachaco-ve/odoo,spadae22/odoo,grap/OpenUpgrade,sinbazhou/odoo,GauravSahu/odoo,hoatle/odoo,Endika/odoo,ingadhoc/odoo,Nowheresly/odoo,nuncjo/odoo,dalegregory/odoo,sv-dev1/odoo,Maspear/odoo,ingadhoc/odoo,dfang/odoo,fevxie/odoo,brijeshkesariya/odoo,datenbetrieb/odoo,VielSoft/odoo,mustafat/odoo-1,shaufi10/odoo,sergio-incaser/odoo,takis/odoo,rahuldhote/odoo,ovnicraft/odoo,NeovaHealth/odoo,ehirt/odoo,x111ong/odoo,rgeleta/odoo,GauravSahu/odoo,incaser/odoo-odoo,hassoon3/odoo,lgscofield/odoo,kybriainfotech/iSocioCRM,cloud9UG/odoo,mszewczy/odoo,x111ong/odoo,draugiskisprendimai/odoo,apanju/GMIO_Odoo,sergio-incaser/odoo,BT-rmartin/odoo,sinbazhou/odoo,lsinfo/odoo,incaser/odoo-odoo,BT-ojossen/odoo,jfpla/odoo,Bachaco-ve/odoo,hassoon3/odoo,goliveirab/odoo,incaser/odoo-odoo,lgscofield/odoo,ApuliaSoftware/odoo,dfang/odoo,ShineFan/odoo,fjbatresv/odoo,rowemoore/odoo,kybriainfotech/iSocioCRM,KontorConsulting/odoo,kittiu/odoo,sinbazhou/odoo,fjbatresv/odoo,ygol/odoo,mlaitinen/odoo,rgeleta/odoo,gorjuce/odoo,BT-ojossen/odoo,Maspear/odoo,xzYue/odoo,ingadhoc/odoo,jiangzhixiao/odoo,draugiskisprendimai/odoo,markeTIC/OCB,salaria/odoo,mszewczy/odoo,cedk/odoo,fuhongliang/odoo,ovnicraft/odoo,grap/OpenUpgrade,optima-ict/odoo,kybriainfotech/iSocioCRM,ygol/odoo,VielSoft/odoo,tvibliani/odoo,windedge/odoo,rgeleta/odoo,ygol/odoo,incaser/odoo-odoo,vnsofthe/odoo,ApuliaSoftware/odoo,fjbatresv/odoo,hassoon3/odoo,Daniel-CA/odoo,hubsaysnuaa/odoo,shingonoide/odoo,luistorresm/odoo,takis/odoo,optima-ict/odoo,n0m4dz/odoo,synconics/odoo,RafaelTorrealba/odoo,sysadminmatmoz/OCB,optima-ict/odoo,hubsaysnuaa/odoo,xzYue/odoo,n0m4dz/odoo,vnsofthe/odoo,makinacorpus/odoo,rowemoore/odoo,Bachaco-ve/odoo,windedge/odoo,goliveirab/odoo,acshan/odoo,fuhongliang/odoo,laslabs/odoo,Antiun/odoo,VielSoft/odoo,microcom/odoo,BT-rmartin/odoo,n0m4dz/odoo,factorlibre/OCB,tinkhaven-organization/odoo,provaleks/o8,synconics/odoo,jfpla/odoo,takis/odoo,brijeshkesariya/odoo,sysadminmatmoz/OCB,makinacorpus/odoo,minhtuancn/odoo,rowemoore/odoo,odootr/odoo,x111ong/odoo,OpenUpgrade/OpenUpgrade,kittiu/odoo,xzYue/odoo,apocalypsebg/odoo,apocalypsebg/odoo,KontorConsulting/odoo,storm-computers/odoo,Bachaco-ve/odoo,glovebx/odoo,eino-makitalo/odoo,mustafat/odoo-1,leorochael/odoo,BT-fgarbely/odoo,hoatle/odoo,cloud9UG/odoo,MarcosCommunity/odoo,gorjuce/odoo,factorlibre/OCB,Endika/odoo,grap/OpenUpgrade,AuyaJackie/odoo,rahuldhote/odoo,draugiskisprendimai/odoo,ecosoft-odoo/odoo,goliveirab/odoo,funkring/fdoo,Endika/OpenUpgrade,x111ong/odoo,shaufi10/odoo,mlaitinen/odoo,GauravSahu/odoo,JGarcia-Panach/odoo,leorochael/odoo,cloud9UG/odoo,provaleks/o8,mlaitinen/odoo,xzYue/odoo,nuncjo/odoo,diagramsoftware/odoo,draugiskisprendimai/odoo,MarcosCommunity/odoo,glovebx/odoo,ShineFan/odoo,kybriainfotech/iSocioCRM,nuncjo/odoo,apanju/GMIO_Odoo,AuyaJackie/odoo,srimai/odoo,Elico-Corp/odoo_OCB,ingadhoc/odoo,shaufi10/odoo,ecosoft-odoo/odoo,cedk/odoo,microcom/odoo,stephen144/odoo,Adel-Magebinary/odoo,jfpla/odoo,Endika/odoo,jfpla/odoo,KontorConsulting/odoo,Maspear/odoo,slevenhagen/odoo,apanju/GMIO_Odoo,synconics/odoo,laslabs/odoo,Antiun/odoo,Daniel-CA/odoo,laslabs/odoo,minhtuancn/odoo,ehirt/odoo,incaser/odoo-odoo,poljeff/odoo,diagramsoftware/odoo,RafaelTorrealba/odoo,gorjuce/odoo,gorjuce/odoo,makinacorpus/odoo,BT-ojossen/odoo,rubencabrera/odoo,AuyaJackie/odoo,dsfsdgsbngfggb/odoo,sv-dev1/odoo,avoinsystems/odoo,MarcosCommunity/odoo,ShineFan/odoo,mlaitinen/odoo,JGarcia-Panach/odoo,sergio-incaser/odoo,acshan/odoo,alexcuellar/odoo,rahuldhote/odoo,cedk/odoo,hanicker/odoo,spadae22/odoo,ApuliaSoftware/odoo,Nowheresly/odoo,OpenUpgrade/OpenUpgrade,lsinfo/odoo,dalegregory/odoo,shaufi/odoo,brijeshkesariya/odoo,factorlibre/OCB,leorochael/odoo,fevxie/odoo,kybriainfotech/iSocioCRM,draugiskisprendimai/odoo,odootr/odoo,ingadhoc/odoo,jiangzhixiao/odoo,makinacorpus/odoo,apanju/GMIO_Odoo,sv-dev1/odoo,Endika/OpenUpgrade,chiragjogi/odoo,Adel-Magebinary/odoo,apocalypsebg/odoo,provaleks/o8,brijeshkesariya/odoo,ovnicraft/odoo,mustafat/odoo-1,tvibliani/odoo,salaria/odoo,diagramsoftware/odoo,Endika/OpenUpgrade,steedos/odoo,shaufi/odoo,rowemoore/odoo,eino-makitalo/odoo,ygol/odoo,hip-odoo/odoo,ovnicraft/odoo,ehirt/odoo,funkring/fdoo,NeovaHealth/odoo,tinkhaven-organization/odoo,glovebx/odoo,vnsofthe/odoo,kybriainfotech/iSocioCRM,odootr/odoo,shaufi/odoo,BT-fgarbely/odoo,fjbatresv/odoo,QianBIG/odoo,Antiun/odoo,mustafat/odoo-1,fevxie/odoo,ChanduERP/odoo,BT-ojossen/odoo,slevenhagen/odoo,poljeff/odoo,slevenhagen/odoo,salaria/odoo,cedk/odoo,Daniel-CA/odoo,vnsofthe/odoo,funkring/fdoo,VielSoft/odoo,stephen144/odoo,steedos/odoo,CatsAndDogsbvba/odoo,Nowheresly/odoo,shingonoide/odoo,shaufi10/odoo,JGarcia-Panach/odoo,tinkhaven-organization/odoo,dariemp/odoo,goliveirab/odoo,sv-dev1/odoo,MarcosCommunity/odoo,odootr/odoo,microcom/odoo,AuyaJackie/odoo,ChanduERP/odoo,hanicker/odoo,mlaitinen/odoo,hubsaysnuaa/odoo,steedos/odoo,rahuldhote/odoo,CatsAndDogsbvba/odoo,dfang/odoo,cloud9UG/odoo,NeovaHealth/odoo,tvibliani/odoo,bplancher/odoo,eino-makitalo/odoo,KontorConsulting/odoo,tangyiyong/odoo,BT-fgarbely/odoo,luistorresm/odoo,ovnicraft/odoo,QianBIG/odoo,Noviat/odoo,steedos/odoo,eino-makitalo/odoo,spadae22/odoo,Bachaco-ve/odoo,Noviat/odoo,spadae22/odoo,provaleks/o8,fevxie/odoo,sysadminmatmoz/OCB,hoatle/odoo,JGarcia-Panach/odoo,dariemp/odoo,kittiu/odoo,alexcuellar/odoo,steedos/odoo,takis/odoo,kittiu/odoo,Adel-Magebinary/odoo,VielSoft/odoo,grap/OpenUpgrade,ecosoft-odoo/odoo,eino-makitalo/odoo,tangyiyong/odoo,markeTIC/OCB,BT-ojossen/odoo,mszewczy/odoo,OpenUpgrade/OpenUpgrade,tinkhaven-organization/odoo,synconics/odoo,apanju/GMIO_Odoo,nuncjo/odoo,goliveirab/odoo,kybriainfotech/iSocioCRM,windedge/odoo,BT-ojossen/odoo,hubsaysnuaa/odoo,dalegregory/odoo