'Update delivered qty in Sales Order for drop ship'

def update_delivered_qty_in_sales_order(self):

    sales_orders_to_update = []
    for item in self.items:
        if (item.sales_order and (item.delivered_by_supplier == 1)):
            if (item.sales_order not in sales_orders_to_update):
                sales_orders_to_update.append(item.sales_order)
    for so_name in sales_orders_to_update:
        so = frappe.get_doc(u'Sales    Order', so_name)
        so.update_delivery_status()
        so.set_status(update=True)
        so.notify_update()
