Magento error log : Cannot add or update a child row: a foreign key constraint fails

When I try to export the catalogue I have a magento error "Cannot add or update a child row: a foreign key constraint fails"

This is not an openerp bug, in my case the error is due to the fact that I delete a website in magento and as the connector is not able to do the same automaticaly. OpenERP still try to export the product on a inexistant website.

This can also appear when you delete other stuff.
So be carefull when you try to delete something in magento.

Have a nice day

Here is the log :

[2010-07-07 16:50:03,519] WARNING:Magento Call:Webservice Failure, sleeping 6 second before next attempt
No LSB modules are available.
[2010-07-07 16:50:09,927] ERROR:web-services01]:
[2010-07-07 16:50:09,927] ERROR:web-services02]: Environment Information :
[2010-07-07 16:50:09,928] ERROR:web-services03]: System : Linux-2.6.24-27-generic-i686-with-debian-lenny-sid
[2010-07-07 16:50:09,928] ERROR:web-services04]: OS Name : posix
[2010-07-07 16:50:09,928] ERROR:web-services05]: Distributor ID: Ubuntu
[2010-07-07 16:50:09,928] ERROR:web-services06]: Description: Ubuntu 8.04.4 LTS
[2010-07-07 16:50:09,928] ERROR:web-services07]: Release: 8.04
[2010-07-07 16:50:09,928] ERROR:web-services08]: Codename: hardy
[2010-07-07 16:50:09,928] ERROR:web-services09]: Operating System Release : 2.6.24-27-generic
[2010-07-07 16:50:09,929] ERROR:web-services10]: Operating System Version : #1 SMP Wed Jan 27 23:54:28 UTC 2010
[2010-07-07 16:50:09,929] ERROR:web-services11]: Operating System Architecture : 32bit
[2010-07-07 16:50:09,929] ERROR:web-services12]: Operating System Locale : fr_FR.UTF8
[2010-07-07 16:50:09,929] ERROR:web-services13]: Python Version : 2.5.2
[2010-07-07 16:50:09,929] ERROR:web-services14]: OpenERP-Server Version : 5.0.9
[2010-07-07 16:50:09,929] ERROR:web-services15]: Last revision No. & ID : 2033 <email address hidden>
[2010-07-07 16:50:09,929] ERROR:web-services16]:
[2010-07-07 16:50:09,929] ERROR:web-services17]: Traceback (most recent call last):
[2010-07-07 16:50:09,930] ERROR:web-services18]: File "/opt/openerp5.0/server/bin/osv/osv.py", line 58, in wrapper
[2010-07-07 16:50:09,930] ERROR:web-services19]: return f(self, dbname, *args, **kwargs)
[2010-07-07 16:50:09,930] ERROR:web-services20]: File "/opt/openerp5.0/server/bin/osv/osv.py", line 119, in execute
[2010-07-07 16:50:09,930] ERROR:web-services21]: res = pool.execute_cr(cr, uid, obj, method, *args, **kw)
[2010-07-07 16:50:09,930] ERROR:web-services22]: File "/opt/openerp5.0/server/bin/osv/osv.py", line 111, in execute_cr
[2010-07-07 16:50:09,930] ERROR:web-services23]: return getattr(object, method)(cr, uid, *args, **kw)
[2010-07-07 16:50:09,930] ERROR:web-services24]: File "/opt/openerp5.0/addons/base_sale_multichannels/sale.py", line 163, in export_catalog
[2010-07-07 16:50:09,930] ERROR:web-services25]: self.export_products(cr, uid, shop, ctx)
[2010-07-07 16:50:09,931] ERROR:web-services26]: File "/opt/openerp5.0/addons/base_sale_multichannels/sale.py", line 155, in export_products
[2010-07-07 16:50:09,931] ERROR:web-services27]: self.export_products_collection(cr, uid, shop, shop.exportable_product_ids, ctx)
[2010-07-07 16:50:09,931] ERROR:web-services28]: File "/opt/openerp5.0/addons/base_sale_multichannels/sale.py", line 152, in export_products_collection
[2010-07-07 16:50:09,931] ERROR:web-services29]: self.pool.get('product.product').ext_export(cr, uid, [product.id for product in shop.exportable_product_ids] , [shop.referential_id.id], {}, ctx)
[2010-07-07 16:50:09,931] ERROR:web-services30]: File "/opt/openerp5.0/addons/magentoerpconnect/product.py", line 890, in ext_export
[2010-07-07 16:50:09,931] ERROR:web-services31]: temp_result = super(magerp_osv.magerp_osv, self).ext_export(cr, uid, [id], external_referential_ids, defaults, ctx_storeview)
[2010-07-07 16:50:09,931] ERROR:web-services32]: File "/opt/openerp5.0/addons/base_external_referentials/external_osv.py", line 309, in ext_export
[2010-07-07 16:50:09,931] ERROR:web-services33]: crid = self.ext_create(cr, uid, exp_data, conn, mapping_rec['external_create_method'], record_data['id'], context)
[2010-07-07 16:50:09,932] ERROR:web-services34]: File "/opt/openerp5.0/addons/magentoerpconnect/product.py", line 830, in ext_create
[2010-07-07 16:50:09,932] ERROR:web-services35]: res = super(magerp_osv.magerp_osv, self).ext_create(cr, uid, [product_type, attr_set_id, sku, data], conn, method, oe_id, ctx)
[2010-07-07 16:50:09,932] ERROR:web-services36]: File "/opt/openerp5.0/addons/base_external_referentials/external_osv.py", line 329, in ext_create
[2010-07-07 16:50:09,932] ERROR:web-services37]: return conn.call(method, data)
[2010-07-07 16:50:09,932] ERROR:web-services38]: File "/opt/openerp5.0/addons/magentoerpconnect/magerp_osv.py", line 53, in call
[2010-07-07 16:50:09,932] ERROR:web-services39]: res = self.ser.call(self.session, method, arguments)
[2010-07-07 16:50:09,932] ERROR:web-services40]: File "/usr/lib/python2.5/xmlrpclib.py", line 1147, in __call__
[2010-07-07 16:50:09,932] ERROR:web-services41]: return self.__send(self.__name, args)
[2010-07-07 16:50:09,933] ERROR:web-services42]: File "/usr/lib/python2.5/xmlrpclib.py", line 1437, in __request
[2010-07-07 16:50:09,933] ERROR:web-services43]: verbose=self.__verbose
[2010-07-07 16:50:09,933] ERROR:web-services44]: File "/usr/lib/python2.5/xmlrpclib.py", line 1201, in request
[2010-07-07 16:50:09,933] ERROR:web-services45]: return self._parse_response(h.getfile(), sock)
[2010-07-07 16:50:09,933] ERROR:web-services46]: File "/usr/lib/python2.5/xmlrpclib.py", line 1340, in _parse_response
[2010-07-07 16:50:09,933] ERROR:web-services47]: return u.close()
[2010-07-07 16:50:09,933] ERROR:web-services48]: File "/usr/lib/python2.5/xmlrpclib.py", line 787, in close
[2010-07-07 16:50:09,933] ERROR:web-services49]: raise Fault(**self._stack[0])
[2010-07-07 16:50:09,934] ERROR:web-services50]: Fault: <Fault 1: 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`TDmagento/tdcatalog_product_website`, CONSTRAINT `FK_CATALOG_PRODUCT_WEBSITE_WEBSITE` FOREIGN KEY (`website_id`) REFERENCES `tdcore_website` (`website_id`) ON DELETE CASCADE ON UPDATE CASCADE)'>

Question information

Language:
English Edit question
Status:
Solved
For:
Magento OpenERP Connector Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Sébastien BEAU - http://www.akretion.com (sebastien.beau) said :
#1

solved