fix: Restore "allow delivery" condition checks (#18246)

* fix: Remove `allow_delivery` flag

- User was not able to create delivery note
because allow_delivery flag was false and
it never used to get updated

* fix: Restore allow_delivery condition checks
diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js
index 26ca7c6..39dda92 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.js
+++ b/erpnext/selling/doctype/sales_order/sales_order.js
@@ -107,7 +107,7 @@
 	refresh: function(doc, dt, dn) {
 		var me = this;
 		this._super();
-		var allow_delivery = false;
+		let allow_delivery = false;
 
 		if(doc.docstatus==1) {
 			if(this.frm.has_perm("submit")) {
@@ -132,6 +132,8 @@
 			if(doc.status !== 'Closed') {
 				if(doc.status !== 'On Hold') {
 
+					allow_delivery = this.frm.doc.items.some(item => item.delivered_by_supplier === 0 && item.qty > flt(item.delivered_qty))
+
 					if (this.frm.has_perm("submit")) {
 						if(flt(doc.per_delivered, 6) < 100 || flt(doc.per_billed) < 100) {
 							// hold