fix: create DN btn should not be shown if it cannot be created

(cherry picked from commit 70ec977cb2)
This commit is contained in:
Mihir Kandoi
2026-01-21 17:13:35 +05:30
committed by Mergify
parent 0b5cc039b6
commit 30e6b5daac
2 changed files with 15 additions and 5 deletions

View File

@@ -116,11 +116,20 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends (
if (cint(doc.update_stock) != 1) {
if (!is_delivered_by_supplier) {
this.frm.add_custom_button(
__("Delivery Note"),
this.frm.cscript["Make Delivery Note"],
__("Create")
const should_create_delivery_note = doc.items.some(
(item) =>
item.qty - item.delivered_qty > 0 &&
!item.scio_detail &&
!item.dn_detail &&
!item.delivered_by_supplier
);
if (should_create_delivery_note) {
this.frm.add_custom_button(
__("Delivery Note"),
this.frm.cscript["Make Delivery Note"],
__("Create")
);
}
}
}

View File

@@ -2424,7 +2424,8 @@ def make_delivery_note(source_name, target_doc=None):
"postprocess": update_item,
"condition": lambda doc: doc.delivered_by_supplier != 1
and not doc.scio_detail
and not doc.dn_detail,
and not doc.dn_detail
and doc.qty - doc.delivered_qty > 0,
},
"Sales Taxes and Charges": {"doctype": "Sales Taxes and Charges", "reset_value": True},
"Sales Team": {