Skip to content

Commit

Permalink
fix: sales order update on delivery trip completion
Browse files Browse the repository at this point in the history
  • Loading branch information
zulfi007 committed Oct 4, 2023
1 parent 9cf8546 commit 34b37cd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions erpnext/stock/doctype/delivery_trip/delivery_trip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 34b37cd

Please sign in to comment.