fix(ux): don't show Create > Packing Slip button if items are already packed

This commit is contained in:
s-aga-r 2023-04-28 18:28:28 +05:30
parent 8d1bccada4
commit da00fc0f16

View File

@ -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) {