fix(woocommerce integration): defaults in settings

This commit is contained in:
karthikeyan5
2019-04-09 15:20:24 +05:30
parent 6784335e2c
commit f788117b3e
6 changed files with 696 additions and 438 deletions

View File

@@ -19,10 +19,11 @@ def verify_request():
frappe.get_request_header("X-Wc-Webhook-Signature") and \
not sig == bytes(frappe.get_request_header("X-Wc-Webhook-Signature").encode()):
frappe.throw(_("Unverified Webhook Data"))
frappe.set_user(woocommerce_settings.modified_by)
frappe.set_user(woocommerce_settings.creation_user)
@frappe.whitelist(allow_guest=True)
def order():
woocommerce_settings = frappe.get_doc("Woocommerce Settings")
if frappe.flags.woocomm_test_order_data:
fd = frappe.flags.woocomm_test_order_data
event = "created"
@@ -69,7 +70,7 @@ def order():
new_sales_order.po_no = fd.get("id")
new_sales_order.woocommerce_id = fd.get("id")
new_sales_order.naming_series = "SO-"
new_sales_order.naming_series = woocommerce_settings.sales_order_series or "SO-WOO-"
placed_order_date = created_date[0]
raw_date = datetime.datetime.strptime(placed_order_date, "%Y-%m-%d")
@@ -96,10 +97,10 @@ def order():
"item_name": found_item.item_name,
"description": found_item.item_name,
"delivery_date":order_delivery_date,
"uom": _("Nos"),
"uom": woocommerce_settings.uom or _("Nos"),
"qty": item.get("quantity"),
"rate": item.get("price"),
"warehouse": "Stores" + " - " + company_abbr
"warehouse": woocommerce_settings.warehouse or "Stores" + " - " + company_abbr
})
add_tax_details(new_sales_order,ordered_items_tax,"Ordered Item tax",0)
@@ -171,6 +172,7 @@ def link_customer_and_address(raw_billing_data,customer_status):
frappe.db.commit()
def link_item(item_data,item_status):
woocommerce_settings = frappe.get_doc("Woocommerce Settings")
if item_status == 0:
#Create Item
@@ -185,7 +187,7 @@ def link_item(item_data,item_status):
item.item_code = "woocommerce - " + str(item_data.get("product_id"))
item.woocommerce_id = str(item_data.get("product_id"))
item.item_group = "WooCommerce Products"
item.stock_uom = _("Nos")
item.stock_uom = woocommerce_settings.uom or _("Nos")
item.save()
frappe.db.commit()