Service Sales order - Delivered status

Good Day,

For Maintenance type sales orders, How can I mark it as delivered. As you know once submitted maintenance SO status shows “to deliver and bill”.

How can i update the delivery status to “completed” as I can not do delivery note for maintenance SO type. even if i did maintenance visit completed still SO not updates

Any Ideas

@Abdelrahman_Aly , Please try the server script.

Script Type : Doctype Event
Ref. Doctype Name : Maintenance Visit
Doctype Event : After Submit

Please change it according to your needs.

if :
    mv = frappe.db.get_value("Maintenance Visit",{'name', "completion_status" : "Fully Completed"}, ['name'])
    mvp = frappe.db.get_value("Maintenance Visit Purpose",{'parent': mv }, ['prevdoc_docname'])
    so = frappe.db.get_value("Sales Order",{'name': mvp }, ['name'])
    if so :
        frappe.db.set_value("Sales Order",{"name":so},{"status":"Completed"})
        frappe.msgprint(_("Sales Order No :   " + so + "   Completed"))