From 5eed4d614474ad24a85870fba92403fd830ab81d Mon Sep 17 00:00:00 2001 From: anhilmy Date: Tue, 13 Aug 2024 13:18:58 +0700 Subject: [PATCH] fix: button fix --- inn/public/js/purchase-order/purchase-order.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/inn/public/js/purchase-order/purchase-order.js b/inn/public/js/purchase-order/purchase-order.js index 775bcb1..0be41fd 100644 --- a/inn/public/js/purchase-order/purchase-order.js +++ b/inn/public/js/purchase-order/purchase-order.js @@ -1,6 +1,6 @@ frappe.ui.form.on("Purchase Order", { refresh: function (frm) { - if (doc.status === 0) { + if (frm.doc.docstatus === 0) { frm.add_custom_button( __("Check Last Purchase"), async function () { @@ -11,6 +11,11 @@ frappe.ui.form.on("Purchase Order", { } ) } + }, + before_save: async function (frm) { + for (const row of frm.doc.items) { + await get_last_purchase(frm, row) + } } })