def validate_access(self): try: get_request('/admin/products.json', {"api_key": self.api_key, "password": self.password, "shopify_url": self.shopify_url, "access_token": self.access_token, "app_type": self.app_type}) except requests.exceptions.HTTPError: self.set("enable_shopify", 0) frappe.throw(_("""Invalid Shopify app credentails or access token"""))
def validate_access(self): try: get_request('/admin/products.json', {"api_key": self.api_key, "password": self.password, "shopify_url": self.shopify_url, "access_token": self.access_token, "app_type": self.app_type}) except requests.exceptions.HTTPError: # disable shopify! frappe.db.rollback() self.set("enable_shopify", 0) frappe.db.commit() frappe.throw(_("""Invalid Shopify app credentials or access token"""), ShopifySetupError)
def execute(): shopify_settings = frappe.db.get_value("Shopify Settings", None, ["enable_shopify", "shopify_url"], as_dict=1) if not (shopify_settings and shopify_settings.enable_shopify and shopify_settings.shopify_url): return try: shopify_orders = get_shopify_orders(ignore_filter_conditions=True) shopify_orders = build_shopify_order_dict(shopify_orders, key="id") except: return for so in frappe.db.sql( """select name, shopify_order_id, discount_amount from `tabSales Order` where shopify_order_id is not null and shopify_order_id != '' and docstatus=1 and discount_amount > 0""", as_dict=1): try: shopify_order = shopify_orders.get(so.shopify_order_id) or {} if so.shopify_order_id not in shopify_orders: shopify_order = get_request("/admin/orders/{0}.json".format( so.shopify_order_id))["order"] if shopify_order.get("taxes_included"): so = frappe.get_doc("Sales Order", so.name) setup_inclusive_taxes(so, shopify_order) so.calculate_taxes_and_totals() so.set_total_in_words() db_update(so) update_si_against_so(so, shopify_order) update_dn_against_so(so, shopify_order) frappe.db.commit() except Exception: pass
def execute(): shopify_settings = frappe.db.get_value("Shopify Settings", None, ["enable_shopify", "shopify_url"], as_dict=1) if not (shopify_settings and shopify_settings.enable_shopify and shopify_settings.shopify_url): return try: shopify_orders = get_shopify_orders(ignore_filter_conditions=True) shopify_orders = build_shopify_order_dict(shopify_orders, key="id") except: return for so in frappe.db.sql("""select name, shopify_order_id, discount_amount from `tabSales Order` where shopify_order_id is not null and shopify_order_id != '' and docstatus=1 and discount_amount > 0""", as_dict=1): try: shopify_order = shopify_orders.get(so.shopify_order_id) or {} if so.shopify_order_id not in shopify_orders: shopify_order = get_request("/admin/orders/{0}.json".format(so.shopify_order_id))["order"] if shopify_order.get("taxes_included"): so = frappe.get_doc("Sales Order", so.name) setup_inclusive_taxes(so, shopify_order) so.calculate_taxes_and_totals() so.set_total_in_words() db_update(so) update_si_against_so(so, shopify_order) update_dn_against_so(so, shopify_order) frappe.db.commit() except Exception: pass