From f1c4aea7b596d632f6d3128e01e0b55b67313561 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 7 Sep 2022 16:38:17 +0530 Subject: [PATCH] fix: option to start reposting from repost item valuation --- .../repost_item_valuation.js | 15 +++++++++++++++ .../repost_item_valuation.py | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.js b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.js index eae73050b2..d595a80b20 100644 --- a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.js +++ b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.js @@ -58,6 +58,21 @@ frappe.ui.form.on('Repost Item Valuation', { } frm.trigger('show_reposting_progress'); + + if (frm.doc.status === 'Queued' && frm.doc.docstatus === 1) { + frm.trigger('execute_reposting'); + } + }, + + execute_reposting(frm) { + frm.add_custom_button(__("Start Reposting"), () => { + frappe.call({ + method: 'erpnext.stock.doctype.repost_item_valuation.repost_item_valuation.execute_repost_item_valuation', + callback: function() { + frappe.msgprint(__('Reposting has been started in the background.')); + } + }); + }); }, show_reposting_progress: function(frm) { diff --git a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py index 7c57ecd73e..c4705246b3 100644 --- a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py +++ b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py @@ -307,3 +307,9 @@ def in_configured_timeslot(repost_settings=None, current_time=None): return end_time >= now_time >= start_time else: return now_time >= start_time or now_time <= end_time + + +@frappe.whitelist() +def execute_repost_item_valuation(): + """Execute repost item valuation via scheduler.""" + frappe.get_doc("Scheduled Job Type", "repost_item_valuation.repost_entries").enqueue(force=True)