Merge pull request #25688 from rohitwaghchaure/fixed-woocommerce-order-sync-issue
fix: Woocommerce order sync issue
This commit is contained in:
commit
0612300631
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe, base64, hashlib, hmac, json
|
import frappe, base64, hashlib, hmac, json
|
||||||
|
from frappe.utils import cstr
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
|
||||||
def verify_request():
|
def verify_request():
|
||||||
@ -146,20 +147,17 @@ def rename_address(address, customer):
|
|||||||
|
|
||||||
def link_items(items_list, woocommerce_settings, sys_lang):
|
def link_items(items_list, woocommerce_settings, sys_lang):
|
||||||
for item_data in items_list:
|
for item_data in items_list:
|
||||||
item_woo_com_id = item_data.get("product_id")
|
item_woo_com_id = cstr(item_data.get("product_id"))
|
||||||
|
|
||||||
if frappe.get_value("Item", {"woocommerce_id": item_woo_com_id}):
|
if not frappe.db.get_value("Item", {"woocommerce_id": item_woo_com_id}, 'name'):
|
||||||
#Edit Item
|
|
||||||
item = frappe.get_doc("Item", {"woocommerce_id": item_woo_com_id})
|
|
||||||
else:
|
|
||||||
#Create Item
|
#Create Item
|
||||||
item = frappe.new_doc("Item")
|
item = frappe.new_doc("Item")
|
||||||
|
item.item_code = _("woocommerce - {0}", sys_lang).format(item_woo_com_id)
|
||||||
|
item.stock_uom = woocommerce_settings.uom or _("Nos", sys_lang)
|
||||||
|
item.item_group = _("WooCommerce Products", sys_lang)
|
||||||
|
|
||||||
item.item_name = item_data.get("name")
|
item.item_name = item_data.get("name")
|
||||||
item.item_code = _("woocommerce - {0}", sys_lang).format(item_data.get("product_id"))
|
item.woocommerce_id = item_woo_com_id
|
||||||
item.woocommerce_id = item_data.get("product_id")
|
|
||||||
item.item_group = _("WooCommerce Products", sys_lang)
|
|
||||||
item.stock_uom = woocommerce_settings.uom or _("Nos", sys_lang)
|
|
||||||
item.flags.ignore_mandatory = True
|
item.flags.ignore_mandatory = True
|
||||||
item.save()
|
item.save()
|
||||||
|
|
||||||
@ -194,12 +192,12 @@ def set_items_in_sales_order(new_sales_order, woocommerce_settings, order, sys_l
|
|||||||
|
|
||||||
for item in order.get("line_items"):
|
for item in order.get("line_items"):
|
||||||
woocomm_item_id = item.get("product_id")
|
woocomm_item_id = item.get("product_id")
|
||||||
found_item = frappe.get_doc("Item", {"woocommerce_id": woocomm_item_id})
|
found_item = frappe.get_doc("Item", {"woocommerce_id": cstr(woocomm_item_id)})
|
||||||
|
|
||||||
ordered_items_tax = item.get("total_tax")
|
ordered_items_tax = item.get("total_tax")
|
||||||
|
|
||||||
new_sales_order.append("items",{
|
new_sales_order.append("items", {
|
||||||
"item_code": found_item.item_code,
|
"item_code": found_item.name,
|
||||||
"item_name": found_item.item_name,
|
"item_name": found_item.item_name,
|
||||||
"description": found_item.item_name,
|
"description": found_item.item_name,
|
||||||
"delivery_date": new_sales_order.delivery_date,
|
"delivery_date": new_sales_order.delivery_date,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user