fix(ux): don't show Create > Packing Slip button if items are already packed
(cherry picked from commit da00fc0f16)
This commit is contained in:
@@ -185,11 +185,30 @@ erpnext.stock.DeliveryNoteController = class DeliveryNoteController extends erpn
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(doc.docstatus==0 && !doc.__islocal) {
|
if(doc.docstatus==0 && !doc.__islocal) {
|
||||||
this.frm.add_custom_button(__('Packing Slip'), function() {
|
var remaining_qty = 0;
|
||||||
frappe.model.open_mapped_doc({
|
|
||||||
method: "erpnext.stock.doctype.delivery_note.delivery_note.make_packing_slip",
|
doc.items.forEach(item => {
|
||||||
frm: me.frm
|
frappe.db.exists("Product Bundle", item.item_code).then(exists => {
|
||||||
}) }, __('Create'));
|
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) {
|
if (!doc.__islocal && doc.docstatus==1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user