Skip to content

Conversation

@SirYancy
Copy link

@SirYancy SirYancy commented Apr 11, 2025

Issue

As per Issue #352 in Shopify integration, when an order is placed, the drop ship status of an item is not carried over into a sales order, even if it is set in Shopify. And you cannot set this flag once a sales order document is submitted.

This PR fixes this issue with a very minor modification to order.py in the shopify integration.
fixed

See the attached issue for details of the bug.

Fix

The fix is simple. When checking if an item exists, it also checks for the delivered_by_supplier flag and verifies that a supplier exists. The supplier has to be there, or the sync will fail. So both the flag and the supplier must exist on the item for this to work.

This snipped contains all changes

       if all_product_exists:  
           item_code = get_item_code(shopify_item)  
           erp_item = frappe.get_doc('Item', item_code)  # Fetch the item from the database
           suppliers = erp_item.get("supplier_items")  # Fetch the list of suppliers
           drop_shipped = erp_item.get("delivered_by_supplier") and len(suppliers) > 0 # Verify the flag and that a supplier exists
           items.append(  
               {  
                   "item_code": item_code,  
                   "item_name": shopify_item.get("name"),  
                   "rate": _get_item_price(shopify_item, taxes_inclusive),  
                   "delivery_date": delivery_date,  
                   "qty": shopify_item.get("quantity"),  
                   "stock_uom": shopify_item.get("uom") or "Nos",  
                   "warehouse": setting.warehouse,  
                   "delivered_by_supplier": 1 if drop_shipped else 0,  # Set flag as appropriate
                   "supplier": suppliers[0] if drop_shipped else "", # Set supplier as appropriate
                   ORDER_ITEM_DISCOUNT_FIELD: (  
                       _get_total_discount(shopify_item) / cint(shopify_item.get("quantity"))  
                   ),  
               }  
           )  

@SirYancy SirYancy requested a review from ankush as a code owner April 11, 2025 18:13
"stock_uom": shopify_item.get("uom") or "Nos",
"warehouse": setting.warehouse,
"delivered_by_supplier": 1 if drop_shipped else 0,
"supplier": suppliers[0] if drop_shipped else "",
Copy link

@Karuppasamy923 Karuppasamy923 May 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Siryancy,

This line assigns the object of the first row rather than the actual supplier name, which may cause issues during sales order creation.

Recommended correction:
"supplier": suppliers[0].supplier if drop_shipped else "",

Update the line as shown above, and can you also rebase the branch with the latest changes from develop?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased and fixed. Let me know if I did that incorrectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants