for variant in variant_list:
erp_varient_item = frappe.get_doc("Item", variant["item_name"])
if (
erp_varient_item.woocommerce_product_id
): # varient exist in woocommerce let's update only
r = put_request(
"products/{0}/variations/{1}".format(
erp_item.woocommerce_product_id,
erp_varient_item.woocommerce_product_id,
),
variant,
)
else:
woocommerce_variant = post_request(
"products/{0}/variations".format(erp_item.woocommerce_product_id),
variant,
)
erp_varient_item.woocommerce_product_id = woocommerce_variant.get("id")
erp_varient_item.woocommerce_variant_id = woocommerce_variant.get("id")
erp_varient_item.save() #<--- this is line 739
Observed result
An error is thrown when saving the item on line 739.
I believe this is only a problem in v13 as people are using this branch in v12 without problems.
Expected result
The item is saved without any exceptions.
Stacktrace / full error message
Traceback (most recent call last):
File "/home/erp/frappe-bench/apps/woocommerceconnector/woocommerceconnector/sync_products.py", line 535, in sync_erpnext_items
sync_item_with_woocommerce(
File "/home/erp/frappe-bench/apps/woocommerceconnector/woocommerceconnector/sync_products.py", line 739, in sync_item_with_woocommerce
erp_varient_item.save()
File "/home/erp/frappe-bench/apps/frappe/frappe/model/document.py", line 285, in save
return self._save(*args, **kwargs)
File "/home/erp/frappe-bench/apps/frappe/frappe/model/document.py", line 314, in _save
self.check_if_latest()
File "/home/erp/frappe-bench/apps/frappe/frappe/model/document.py", line 725, in check_if_latest
frappe.msgprint(_("Error: Document has been modified after you have opened it") \
File "/home/erp/frappe-bench/apps/frappe/frappe/__init__.py", line 411, in msgprint
_raise_exception()
File "/home/erp/frappe-bench/apps/frappe/frappe/__init__.py", line 365, in _raise_exception
raise raise_exception(msg)
frappe.exceptions.TimestampMismatchError: Error: Document has been modified after you have opened it (2021-06-15 20:22:22.159850, 2021-06-16 20:06:02.811495). Please refresh to get the latest document.
Context information (for bug reports)
Output of
bench version
Problematic code
Observed result
An error is thrown when saving the item on line 739. I believe this is only a problem in v13 as people are using this branch in v12 without problems.
Expected result
The item is saved without any exceptions.
Stacktrace / full error message
Additional information
ubuntu 20.04 with production settings