From 34b37cdcf658ccb22aca32b4178e44a666696ab8 Mon Sep 17 00:00:00 2001 From: zulfi007 Date: Wed, 4 Oct 2023 09:05:20 +0000 Subject: [PATCH] fix: sales order update on delivery trip completion --- erpnext/stock/doctype/delivery_trip/delivery_trip.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/delivery_trip/delivery_trip.py b/erpnext/stock/doctype/delivery_trip/delivery_trip.py index d4f8f989fa80..2b43cb1179bc 100644 --- a/erpnext/stock/doctype/delivery_trip/delivery_trip.py +++ b/erpnext/stock/doctype/delivery_trip/delivery_trip.py @@ -77,16 +77,19 @@ def update_sales_order_status(self, cancel=False): processed_so_details=set() for sales_order in sales_orders: # sales_order_doc = frappe.get_doc("Sales Order", sales_order['sales_order']) - status = invoices.get(sales_order['parent'], 0) + invoice_status = invoices.get(sales_order['parent'], 0) if sales_order['sales_order'] in processed_so_details: continue processed_so_details.add(sales_order['sales_order']) - delivery_status = 'Not Delivered' if cancel else ('Fully Delivered' if status == 1 else 'In Transit') + delivery_status = 'Not Delivered' if cancel else ('Fully Delivered' if invoice_status == 1 else 'In Transit') frappe.db.set_value("Sales Order", sales_order['sales_order'], "delivery_status", delivery_status) + order_status = 'To Deliver' if cancel else ('Completed' if invoice_status == 1 else 'To Deliver and Bill') + frappe.db.set_value("Sales Order", sales_order['sales_order'], "status", order_status) + def update_sales_invoices(self, cancel=False): """ Update all connected Sales Invoices with Delivery Trip details