Shopify Connector Error: Document has been modified after you have opened it

In the Ecommerce Integration log I have the following error:

Integration
shopify

Status
Error

Method
ecommerce_integrations.shopify.order.sync_sales_order

Message
Error: Document has been modified after you have opened it (2022-04-12 18:33:11.500360, 2022-04-12 18:33:11.588083). Please refresh to get the latest document.
Traceback
Traceback (most recent call last):
  File "apps/ecommerce_integrations/ecommerce_integrations/shopify/order.py", line 49, in sync_sales_order
    create_order(order, setting)
  File "apps/ecommerce_integrations/ecommerce_integrations/shopify/order.py", line 61, in create_order
    so = create_sales_order(order, setting, company)
  File "apps/ecommerce_integrations/ecommerce_integrations/shopify/order.py", line 119, in create_sales_order
    so.submit()
  File "apps/frappe/frappe/model/document.py", line 943, in submit
    return self._submit()
  File "apps/frappe/frappe/model/document.py", line 932, in _submit
    return self.save()
  File "apps/frappe/frappe/model/document.py", line 287, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 318, in _save
    self.check_if_latest()
  File "apps/frappe/frappe/model/document.py", line 732, in check_if_latest
    frappe.msgprint(_("Error: Document has been modified after you have opened it") \
  File "apps/frappe/frappe/__init__.py", line 423, in msgprint
    _raise_exception()
  File "apps/frappe/frappe/__init__.py", line 378, in _raise_exception
    raise raise_exception(msg)
frappe.exceptions.TimestampMismatchError: Error: Document has been modified after you have opened it (2022-04-12 18:33:11.500360, 2022-04-12 18:33:11.588083). Please refresh to get the latest document.

I am not sure what to do to get this order to sync. Anyone have any suggestions?

Thanks!

Scott =)

All of my webhooks are now returning this same error. Something changed and now the connector is not working.

When a script is creating something like in create_sales_order() how can the document have been modified since it was opened? It doesn’t exist yet in the database.

This is all very puzzling. I am still digging into it.

Thanks!

Scott =)

In apps/ecommerce_integrations/ecommerce_integrations/shopify/order.py if I comment out so.submit() it will create the order in a draft form. So something seems to be modifying the order (or it thinks it is) between these two lines:

so.save(ignore_permissions=True)
so.submit()

Thanks!

Scott =)

Do you maybe have some hooks/server scritps that modify it in DB on save?

There hasn’t been any change in integration, so suddenly getting this error is bit weird.

I have not installed anything extra. I only have the base erpnext and the ecommerce app.

I didn’t change anything when the order failed on Tuesday. The hook started failing yesterday.

I am trying to figure out what changed.

Thanks!

Scott =)

When I try to call the hook directly I get:

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 68, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 55, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 31, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 68, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1213, in call
    return fn(*args, **newargs)
  File "apps/ecommerce_integrations/ecommerce_integrations/shopify/connection.py", line 98, in store_request_data
    _validate_request(frappe.request, hmac_header)
  File "apps/ecommerce_integrations/ecommerce_integrations/shopify/connection.py", line 128, in _validate_request
    create_shopify_log(status="Error", request_data=req.data)
  File "apps/ecommerce_integrations/ecommerce_integrations/shopify/utils.py", line 19, in create_shopify_log
    return create_log(module_def=MODULE_NAME, **kwargs)
  File "apps/ecommerce_integrations/ecommerce_integrations/ecommerce_integrations/doctype/ecommerce_integration_log/ecommerce_integration_log.py", line 65, in create_log
    log.save(ignore_permissions=True)
  File "apps/frappe/frappe/model/document.py", line 287, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 318, in _save
    self.check_if_latest()
  File "apps/frappe/frappe/model/document.py", line 732, in check_if_latest
    frappe.msgprint(_("Error: Document has been modified after you have opened it") \
  File "apps/frappe/frappe/__init__.py", line 423, in msgprint
    _raise_exception()
  File "apps/frappe/frappe/__init__.py", line 378, in _raise_exception
    raise raise_exception(msg)
frappe.exceptions.TimestampMismatchError: Error: Document has been modified after you have opened it (2022-04-15 09:35:21.368145, 2022-04-15 09:35:21.543169). Please refresh to get the latest document.

So it can’t seem to create even error logs at the moment.

Thanks!

Scott =)

I have not installed any that I know of. Where would I find these hooks? I will look to see if something else installed something.

Thanks!

Scott =)

I think I may have found it.

A notification on status of “New” for the ecommerce integration log to tell me when a new error message came in.

I am thinking I need to do it on “Submit” not on “New”. There should be some sort of warning about this, because the error made it non-obvious.

I am going to keep testing, but I am getting logs again.

Thanks!

Scott =)

This was indeed caused by my notification settings.

Setting notifications on ‘New’ or ‘Save’ for the Ecommerce Integration Log or Sales Ordres does indeed cause this to happen.