Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing order fails due to constraint re-importing customer. #270

Open
jaredkipe opened this issue Nov 28, 2017 · 0 comments
Open

Importing order fails due to constraint re-importing customer. #270

jaredkipe opened this issue Nov 28, 2017 · 0 comments

Comments

@jaredkipe
Copy link

A customer with an existing order/address binding can sometimes fail like this.

Traceback (most recent call last):
  File "/opt/odoo/addons/queue_job/controllers/main.py", line 86, in runjob
    self._try_perform_job(env, job)
  File "/opt/odoo/addons/queue_job/controllers/main.py", line 62, in _try_perform_job
    job.perform()
  File "/opt/odoo/addons/queue_job/job.py", line 369, in perform
    self.result = self.func(*tuple(self.args), **self.kwargs)
  File "/opt/odoo/addons/connector_magento/models/magento_binding/common.py", line 52, in import_record
    return importer.run(external_id, force=force)
  File "/opt/odoo/addons/connector_magento/components/importer.py", line 207, in run
    self._import_dependencies()
  File "/opt/odoo/addons/connector_magento/models/sale_order/importer.py", line 668, in _import_dependencies
    self._import_addresses()
  File "/opt/odoo/addons/connector_magento/models/sale_order/importer.py", line 584, in _import_addresses
    importer.run(record['customer_id'])
  File "/opt/odoo/addons/connector_magento/components/importer.py", line 220, in run
    self._after_import(binding)
  File "/opt/odoo/addons/connector_magento/models/partner/importer.py", line 153, in _after_import
    book.import_addresses(self.external_id, partner_binding.id)
  File "/opt/odoo/addons/connector_magento/models/partner/importer.py", line 198, in import_addresses
    importer.run(address_id, address_infos=infos)
  File "/opt/odoo/addons/connector_magento/models/partner/importer.py", line 372, in run
    return super(AddressImporter, self).run(external_id, force=force)
  File "/opt/odoo/addons/connector_magento/components/importer.py", line 216, in run
    binding = self._create(record)
  File "/opt/odoo/addons/connector_magento/models/partner/importer.py", line 402, in _create
    return super(AddressImporter, self)._create(data)
  File "/opt/odoo/addons/connector_magento/components/importer.py", line 154, in _create
    binding = model.create(data)
  File "/opt/odoo/addons/connector/producer.py", line 30, in create
    record = super(Base, self).create(vals)
  File "/opt/odoo/addons/component_event/models/base.py", line 93, in create
    record = super(Base, self).create(vals)
  File "/usr/local/lib/python2.7/site-packages/odoo/models.py", line 3826, in create
    record = self.browse(self._create(old_vals))
  File "/usr/local/lib/python2.7/site-packages/odoo/models.py", line 3985, in _create
    self.recompute()
  File "/usr/local/lib/python2.7/site-packages/odoo/models.py", line 5320, in recompute
    recs.browse(ids)._write(dict(vals))
  File "/usr/local/lib/python2.7/site-packages/odoo/models.py", line 3646, in _write
    cr.execute(query, params + (sub_ids,))
  File "/usr/local/lib/python2.7/site-packages/odoo/sql_db.py", line 154, in wrapper
    return f(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/odoo/sql_db.py", line 231, in execute
    res = self._obj.execute(query, params)
IntegrityError: duplicate key value violates unique constraint "magento_address_odoo_uniq"
DETAIL:  Key (backend_id, odoo_id)=(1, 39216) already exists.

Though I don't know what causes it (I haven't been able to replicate it), the solution is basically to just DELETE FROM magento_address WHERE odoo_id = 39216;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant