fix: do not run bg job for single doc

This commit is contained in:
Gursheen Anand 2023-09-23 19:30:42 +05:30
parent a856091ff4
commit 1856050ef9

View File

@ -139,14 +139,17 @@ class RepostAccountingLedger(Document):
return rendered_page return rendered_page
def on_submit(self): def on_submit(self):
job_name = "repost_accounting_ledger_" + self.name if len(self.vouchers) > 1:
frappe.enqueue( job_name = "repost_accounting_ledger_" + self.name
method="erpnext.accounts.doctype.repost_accounting_ledger.repost_accounting_ledger.start_repost", frappe.enqueue(
account_repost_doc=self.name, method="erpnext.accounts.doctype.repost_accounting_ledger.repost_accounting_ledger.start_repost",
is_async=True, account_repost_doc=self.name,
job_name=job_name, is_async=True,
) job_name=job_name,
frappe.msgprint(_("Repost has started in the background")) )
frappe.msgprint(_("Repost has started in the background"))
else:
start_repost(self.name)
@frappe.whitelist() @frappe.whitelist()