Skip to content

Commit

Permalink
fix(ux): don't show Create > Packing Slip button if items are alrea…
Browse files Browse the repository at this point in the history
…dy packed

(cherry picked from commit da00fc0)
  • Loading branch information
s-aga-r authored and mergify[bot] committed May 25, 2023
1 parent 4017342 commit 9854c84
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions erpnext/stock/doctype/delivery_note/delivery_note.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,30 @@ erpnext.stock.DeliveryNoteController = class DeliveryNoteController extends erpn
}

if(doc.docstatus==0 && !doc.__islocal) {
this.frm.add_custom_button(__('Packing Slip'), function() {
frappe.model.open_mapped_doc({
method: "erpnext.stock.doctype.delivery_note.delivery_note.make_packing_slip",
frm: me.frm
}) }, __('Create'));
var remaining_qty = 0;

doc.items.forEach(item => {
frappe.db.exists("Product Bundle", item.item_code).then(exists => {
if (!exists) {
remaining_qty += (item.qty - item.packed_qty);
}
});
});

if (!remaining_qty) {
doc.packed_items.forEach(item => {
remaining_qty += (item.qty - item.packed_qty);
});
}

if (remaining_qty > 0) {
this.frm.add_custom_button(__('Packing Slip'), function() {
frappe.model.open_mapped_doc({
method: "erpnext.stock.doctype.delivery_note.delivery_note.make_packing_slip",
frm: me.frm
}) }, __('Create')
);
}
}

if (!doc.__islocal && doc.docstatus==1) {
Expand Down

0 comments on commit 9854c84

Please sign in to comment.