Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
nabinhait committed Apr 4, 2018
2 parents 31a7443 + 68758bb commit bdf6d88
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion erpnext_shopify/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from __future__ import unicode_literals, absolute_import

__version__ = "2.0.25"
__version__ = "2.0.26"
2 changes: 1 addition & 1 deletion erpnext_shopify/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion erpnext_shopify/patches/V1_0/set_variant_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions erpnext_shopify/patches/V2_0/refactor_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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))
8 changes: 4 additions & 4 deletions erpnext_shopify/sync_customers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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 = ""
Expand Down
4 changes: 2 additions & 2 deletions erpnext_shopify/sync_orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 9 additions & 9 deletions erpnext_shopify/sync_products.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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"] = ''
Expand Down Expand Up @@ -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:
Expand All @@ -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)
Expand Down

0 comments on commit bdf6d88

Please sign in to comment.