When I submit the document it shows the message but it doesn’t stop me from submitting the document.
In client side I used before_submit event.
@frappe.whitelist()
def update_delivery_status(doc, dn_doc):
so = frappe.get_doc(“Sales Order”, doc)
dn = frappe.get_doc(“Delivery Note”, dn_doc)
so_qty = sum( item.qty for item in so.items )
dn_qty = sum( item.qty for item in dn.items)
per_delivered = (dn_qty / so_qty) * 100
if (so.docstatus == 1 and so.custom_is_service_order and dn and so):
if (per_delivered < 100):
frappe.throw("The delivery note quantity for the item does not match the sales order quantity.")