Merge pull request #51969 from frappe/mergify/bp/version-15-hotfix/pr-51964

fix: create DN btn should not be shown if it cannot be created (backport #51964)
This commit is contained in:
mergify[bot]
2026-01-21 17:27:37 +00:00
committed by GitHub
parent e54bb0da69
commit c35426b9f9
2 changed files with 15 additions and 5 deletions

View File

@@ -118,11 +118,19 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends (
});
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.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

@@ -2211,7 +2211,9 @@ def make_delivery_note(source_name, target_doc=None):
"cost_center": "cost_center",
},
"postprocess": update_item,
"condition": lambda doc: doc.delivered_by_supplier != 1 and not doc.dn_detail,
"condition": lambda doc: doc.delivered_by_supplier != 1
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": {