diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js index 5bf79474fbe81d030c8bfa26dc577f67bb554a7a..c4177a4a85c3d0a63981137e781489a9f8d99237 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.js +++ b/erpnext/buying/doctype/purchase_order/purchase_order.js @@ -311,22 +311,38 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends e } if(doc.status != "Closed") { if (doc.status != "On Hold") { - if(flt(doc.per_received, 2) < 100 && allow_receipt) { - cur_frm.add_custom_button(__('Purchase Receipt'), this.make_purchase_receipt, __('Create')); + if (flt(doc.per_received, 2) < 100 && allow_receipt) { + this.frm.add_custom_button( + __("Purchase Receipt"), + () => { + me.make_purchase_receipt(); + }, + __("Create") + ); if (doc.is_subcontracted) { if (doc.is_old_subcontracting_flow) { if (me.has_unsupplied_items()) { cur_frm.add_custom_button(__('Material to Supplier'), function() { me.make_stock_entry(); }, __("Transfer")); } - } - else { - cur_frm.add_custom_button(__('Subcontracting Order'), this.make_subcontracting_order, __('Create')); + } else { + this.frm.add_custom_button( + __("Subcontracting Order"), + () => { + me.make_subcontracting_order(); + }, + __("Create") + ); } } } - if(flt(doc.per_billed, 2) < 100) - cur_frm.add_custom_button(__('Purchase Invoice'), - this.make_purchase_invoice, __('Create')); + if (flt(doc.per_billed, 2) < 100) + this.frm.add_custom_button( + __("Purchase Invoice"), + () => { + me.make_purchase_invoice(); + }, + __("Create") + ); if(flt(doc.per_billed, 2) < 100 && doc.status != "Delivered") { this.frm.add_custom_button(