diff --git a/erpnext_shopify/__init__.py b/erpnext_shopify/__init__.py index eb333239..ecfc7369 100644 --- a/erpnext_shopify/__init__.py +++ b/erpnext_shopify/__init__.py @@ -1,3 +1,3 @@ from __future__ import unicode_literals, absolute_import -__version__ = "2.0.25" +__version__ = "2.0.26" diff --git a/erpnext_shopify/api.py b/erpnext_shopify/api.py index 9573c331..f9ad3d74 100644 --- a/erpnext_shopify/api.py +++ b/erpnext_shopify/api.py @@ -38,7 +38,7 @@ def sync_shopify_resources(): make_shopify_log(title="Sync Completed", status="Success", method=frappe.local.form_dict.cmd, message= "Updated {customers} customer(s), {products} item(s), {orders} order(s)".format(**frappe.local.form_dict.count_dict)) - except Exception, e: + except Exception as e: if e.args[0] and hasattr(e.args[0], "startswith") and e.args[0].startswith("402"): make_shopify_log(title="Shopify has suspended your account", status="Error", method="sync_shopify_resources", message=_("""Shopify has suspended your account till diff --git a/erpnext_shopify/erpnext_shopify/doctype/shopify_settings/shopify_settings.js b/erpnext_shopify/erpnext_shopify/doctype/shopify_settings/shopify_settings.js index b9facdca..04ce4840 100644 --- a/erpnext_shopify/erpnext_shopify/doctype/shopify_settings/shopify_settings.js +++ b/erpnext_shopify/erpnext_shopify/doctype/shopify_settings/shopify_settings.js @@ -60,7 +60,7 @@ frappe.ui.form.on("Shopify Settings", "refresh", function(frm){ {"fieldtype": "Button", "label": __("Set last sync date"), "fieldname": "set_last_sync_date", "cssClass": "btn-primary"}, ] }); - + var args; dialog.fields_dict.set_last_sync_date.$input.click(function() { args = dialog.get_values(); if(!args) return; diff --git a/erpnext_shopify/patches/V1_0/set_variant_id.py b/erpnext_shopify/patches/V1_0/set_variant_id.py index 53dd17a7..6e6973c5 100644 --- a/erpnext_shopify/patches/V1_0/set_variant_id.py +++ b/erpnext_shopify/patches/V1_0/set_variant_id.py @@ -21,7 +21,7 @@ def execute(): try: shopify_items = get_item_list() except ShopifyError: - print "Could not run shopify patch 'set_variant_id' for site: {0}".format(frappe.local.site) + print("Could not run shopify patch 'set_variant_id' for site: {0}".format(frappe.local.site)) return if shopify_settings.shopify_url and shopify_items: diff --git a/erpnext_shopify/patches/V2_0/refactor_id.py b/erpnext_shopify/patches/V2_0/refactor_id.py index 5067692b..6d4ba9ad 100644 --- a/erpnext_shopify/patches/V2_0/refactor_id.py +++ b/erpnext_shopify/patches/V2_0/refactor_id.py @@ -2,6 +2,7 @@ # License: GNU General Public License v3. See license.txt import frappe from frappe.utils.fixtures import sync_fixtures +from six import iteritems def execute(): sync_fixtures("erpnext_shopify") @@ -11,11 +12,11 @@ def execute(): frappe.reload_doctype("Delivery Note") frappe.reload_doctype("Sales Invoice") - for doctype, column in {"Customer": "shopify_customer_id", + for doctype, column in iteritems({"Customer": "shopify_customer_id", "Item": "shopify_product_id", "Sales Order": "shopify_order_id", "Delivery Note": "shopify_order_id", - "Sales Invoice": "shopify_order_id"}.items(): + "Sales Invoice": "shopify_order_id"}): if "shopify_id" in frappe.db.get_table_columns(doctype): frappe.db.sql("update `tab%s` set %s=shopify_id" % (doctype, column)) \ No newline at end of file diff --git a/erpnext_shopify/sync_customers.py b/erpnext_shopify/sync_customers.py index 70a79fcb..871e5334 100644 --- a/erpnext_shopify/sync_customers.py +++ b/erpnext_shopify/sync_customers.py @@ -45,7 +45,7 @@ def create_customer(shopify_customer, shopify_customer_list): shopify_customer_list.append(shopify_customer.get("id")) frappe.db.commit() - except Exception, e: + except Exception as e: if e.args[0] and e.args[0].startswith("402"): raise e else: @@ -78,7 +78,7 @@ def create_customer_address(customer, shopify_customer): }] }).insert(ignore_mandatory=True) - except Exception, e: + except Exception as e: make_shopify_log(title=e.message, status="Error", method="create_customer_address", message=frappe.get_traceback(), request_data=shopify_customer, exception=True) @@ -114,7 +114,7 @@ def sync_erpnext_customers(shopify_customer_list): frappe.local.form_dict.count_dict["customers"] += 1 frappe.db.commit() - except Exception, e: + except Exception as e: make_shopify_log(title=e.message, status="Error", method="sync_erpnext_customers", message=frappe.get_traceback(), request_data=customer, exception=True) @@ -156,7 +156,7 @@ def update_customer_to_shopify(customer, last_sync_datetime): { "customer": shopify_customer}) update_address_details(customer, last_sync_datetime) - except requests.exceptions.HTTPError, e: + except requests.exceptions.HTTPError as e: if e.args[0] and e.args[0].startswith("404"): customer = frappe.get_doc("Customer", customer.name) customer.shopify_customer_id = "" diff --git a/erpnext_shopify/sync_orders.py b/erpnext_shopify/sync_orders.py index 3955e36c..e93394c3 100644 --- a/erpnext_shopify/sync_orders.py +++ b/erpnext_shopify/sync_orders.py @@ -23,10 +23,10 @@ def sync_shopify_orders(): create_order(shopify_order, shopify_settings) frappe.local.form_dict.count_dict["orders"] += 1 - except ShopifyError, e: + except ShopifyError as e: make_shopify_log(status="Error", method="sync_shopify_orders", message=frappe.get_traceback(), request_data=shopify_order, exception=True) - except Exception, e: + except Exception as e: if e.args and e.args[0] and e.args[0].decode("utf-8").startswith("402"): raise e else: diff --git a/erpnext_shopify/sync_products.py b/erpnext_shopify/sync_products.py index 8aefc054..8f09d290 100644 --- a/erpnext_shopify/sync_products.py +++ b/erpnext_shopify/sync_products.py @@ -22,11 +22,11 @@ def sync_shopify_items(warehouse, shopify_item_list): try: make_item(warehouse, shopify_item, shopify_item_list) - except ShopifyError, e: + except ShopifyError as e: make_shopify_log(title=e.message, status="Error", method="sync_shopify_items", message=frappe.get_traceback(), request_data=shopify_item, exception=True) - except Exception, e: + except Exception as e: if e.args[0] and e.args[0].startswith("402"): raise e else: @@ -278,7 +278,7 @@ def is_item_exists(shopify_item, attributes=None, variant_of=None, shopify_item_ item.shopify_product_id = shopify_item.get("shopify_product_id") item.shopify_variant_id = shopify_item.get("shopify_variant_id") item.save() - return False + return True if item.shopify_product_id and attributes and attributes[0].get("attribute_value"): if not variant_of: @@ -341,10 +341,10 @@ def sync_erpnext_items(price_list, warehouse, shopify_item_list): sync_item_with_shopify(item, price_list, warehouse) frappe.local.form_dict.count_dict["products"] += 1 - except ShopifyError, e: + except ShopifyError as e: make_shopify_log(title=e.message, status="Error", method="sync_shopify_items", message=frappe.get_traceback(), request_data=item, exception=True) - except Exception, e: + except Exception as e: make_shopify_log(title=e.message, status="Error", method="sync_shopify_items", message=frappe.get_traceback(), request_data=item, exception=True) @@ -427,7 +427,7 @@ def sync_item_with_shopify(item, price_list, warehouse): try: put_request("/admin/products/{}.json".format(item.get("shopify_product_id")), item_data) - except requests.exceptions.HTTPError, e: + except requests.exceptions.HTTPError as e: if e.args[0] and e.args[0].startswith("404"): if frappe.db.get_value("Shopify Settings", "Shopify Settings", "if_not_exists_create_item_to_shopify"): item_data["product"]["id"] = '' @@ -590,11 +590,11 @@ def update_item_stock_qty(): filters={"sync_with_shopify": 1, "disabled": ("!=", 1), 'shopify_variant_id': ('!=', '')}): try: update_item_stock(item.item_code, shopify_settings) - except ShopifyError, e: + except ShopifyError as e: make_shopify_log(title=e.message, status="Error", method="sync_shopify_items", message=frappe.get_traceback(), request_data=item, exception=True) - except Exception, e: + except Exception as e: if e.args[0] and e.args[0].startswith("402"): raise e else: @@ -621,7 +621,7 @@ def update_item_stock(item_code, shopify_settings, bin=None): try: put_request(resource, item_data) - except requests.exceptions.HTTPError, e: + except requests.exceptions.HTTPError as e: if e.args[0] and e.args[0].startswith("404"): make_shopify_log(title=e.message, status="Error", method="sync_shopify_items", message=frappe.get_traceback(), request_data=item_data, exception=True)