From be20d74d978b83e4409eaca05ab5d42473001348 Mon Sep 17 00:00:00 2001 From: Vikas8600 Date: Tue, 2 May 2023 16:04:47 +0530 Subject: [PATCH] fix: code changes --- ecommerce_integrations/unicommerce/constants.py | 1 - .../unicommerce_settings/unicommerce_settings.json | 4 ++-- ecommerce_integrations/unicommerce/order.py | 12 ++---------- ecommerce_integrations/unicommerce/product.py | 2 ++ 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/ecommerce_integrations/unicommerce/constants.py b/ecommerce_integrations/unicommerce/constants.py index ab046674..3b3da571 100644 --- a/ecommerce_integrations/unicommerce/constants.py +++ b/ecommerce_integrations/unicommerce/constants.py @@ -34,7 +34,6 @@ IS_COD_CHECKBOX = "unicommerce_is_cod" SHIPPING_METHOD_FIELD = "unicommerce_shipping_method" SHIPPIND_ID = "unicommerce_shipment_id" - GRN_STOCK_ENTRY_TYPE = "GRN on Unicommerce" diff --git a/ecommerce_integrations/unicommerce/doctype/unicommerce_settings/unicommerce_settings.json b/ecommerce_integrations/unicommerce/doctype/unicommerce_settings/unicommerce_settings.json index d6d86f96..16aedf9e 100644 --- a/ecommerce_integrations/unicommerce/doctype/unicommerce_settings/unicommerce_settings.json +++ b/ecommerce_integrations/unicommerce/doctype/unicommerce_settings/unicommerce_settings.json @@ -261,13 +261,13 @@ "default": "0", "fieldname": "delivery_note", "fieldtype": "Check", - "label": "Generate Delivery Note" + "label": "Import Delivery Notes from Unicommerce on Shipment" } ], "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2023-05-02 10:36:07.140401", + "modified": "2023-05-02 14:04:26.684256", "modified_by": "Administrator", "module": "unicommerce", "name": "Unicommerce Settings", diff --git a/ecommerce_integrations/unicommerce/order.py b/ecommerce_integrations/unicommerce/order.py index 79fbf629..dc1d0a6a 100644 --- a/ecommerce_integrations/unicommerce/order.py +++ b/ecommerce_integrations/unicommerce/order.py @@ -78,10 +78,8 @@ def _get_new_orders( for order in uni_orders: if order["channel"] not in configured_channels: continue + #In case a sales invoice is not generated for some reason and is skipped, we need to create it manually. Therefore, I have commented out this line of code. - # if frappe.db.exists("Sales Order", {ORDER_CODE_FIELD: order["code"]}): - # continue - order = client.get_sales_order(order_code=order["code"]) if order: yield order @@ -122,18 +120,12 @@ def create_order(payload: UnicommerceOrder, request_id: Optional[str] = None, cl order = payload - # if request_id is None: - # log = create_unicommerce_log( - # method="ecommerce_integrations.unicommerce.order.create_order", request_data=payload - # ) - # request_id = log.name - existing_so = frappe.db.get_value("Sales Order", {ORDER_CODE_FIELD: order["code"]}) if existing_so: so = frappe.get_doc("Sales Order", existing_so) - # create_unicommerce_log(status="Invalid", message="Sales Order already exists, skipped") return so + #If a sales order already exists, then every time it's executed if request_id is None: log = create_unicommerce_log( method="ecommerce_integrations.unicommerce.order.create_order", request_data=payload diff --git a/ecommerce_integrations/unicommerce/product.py b/ecommerce_integrations/unicommerce/product.py index dcdf0990..e12cee34 100644 --- a/ecommerce_integrations/unicommerce/product.py +++ b/ecommerce_integrations/unicommerce/product.py @@ -248,6 +248,7 @@ def upload_items_to_unicommerce( for item_code in item_codes: item_data = _build_unicommerce_item(item_code) sku = item_data.get("skuCode") + item_exists = bool(client.get_unicommerce_item(sku, log_error=False)) _, status = client.create_update_item(item_data, update=item_exists) @@ -291,6 +292,7 @@ def _build_unicommerce_item(item_code: ItemCode) -> JsonDict: item_json["maxRetailPrice"] = item.standard_rate item_json["description"] = frappe.utils.strip_html_tags(item.description) item_json["costPrice"] = item.valuation_rate + return item_json