refactor: use job_id
instead of job_name
(#35242)
depends on https://github.com/frappe/frappe/pull/20951
This commit is contained in:
parent
5d43b35d20
commit
2ea38333f0
@ -53,19 +53,20 @@ class BankStatementImport(DataImport):
|
|||||||
if "Bank Account" not in json.dumps(preview["columns"]):
|
if "Bank Account" not in json.dumps(preview["columns"]):
|
||||||
frappe.throw(_("Please add the Bank Account column"))
|
frappe.throw(_("Please add the Bank Account column"))
|
||||||
|
|
||||||
from frappe.utils.background_jobs import is_job_queued
|
from frappe.utils.background_jobs import is_job_enqueued
|
||||||
from frappe.utils.scheduler import is_scheduler_inactive
|
from frappe.utils.scheduler import is_scheduler_inactive
|
||||||
|
|
||||||
if is_scheduler_inactive() and not frappe.flags.in_test:
|
if is_scheduler_inactive() and not frappe.flags.in_test:
|
||||||
frappe.throw(_("Scheduler is inactive. Cannot import data."), title=_("Scheduler Inactive"))
|
frappe.throw(_("Scheduler is inactive. Cannot import data."), title=_("Scheduler Inactive"))
|
||||||
|
|
||||||
if not is_job_queued(self.name):
|
job_id = f"bank_statement_import::{self.name}"
|
||||||
|
if not is_job_enqueued(job_id):
|
||||||
enqueue(
|
enqueue(
|
||||||
start_import,
|
start_import,
|
||||||
queue="default",
|
queue="default",
|
||||||
timeout=6000,
|
timeout=6000,
|
||||||
event="data_import",
|
event="data_import",
|
||||||
job_name=self.name,
|
job_id=job_id,
|
||||||
data_import=self.name,
|
data_import=self.name,
|
||||||
bank_account=self.bank_account,
|
bank_account=self.bank_account,
|
||||||
import_file_path=self.import_file,
|
import_file_path=self.import_file,
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.utils.background_jobs import is_job_queued
|
from frappe.utils.background_jobs import is_job_enqueued
|
||||||
|
|
||||||
from erpnext.accounts.doctype.account.account import merge_account
|
from erpnext.accounts.doctype.account.account import merge_account
|
||||||
|
|
||||||
@ -17,13 +17,14 @@ class LedgerMerge(Document):
|
|||||||
if is_scheduler_inactive() and not frappe.flags.in_test:
|
if is_scheduler_inactive() and not frappe.flags.in_test:
|
||||||
frappe.throw(_("Scheduler is inactive. Cannot merge accounts."), title=_("Scheduler Inactive"))
|
frappe.throw(_("Scheduler is inactive. Cannot merge accounts."), title=_("Scheduler Inactive"))
|
||||||
|
|
||||||
if not is_job_queued(self.name):
|
job_id = f"ledger_merge::{self.name}"
|
||||||
|
if not is_job_enqueued(job_id):
|
||||||
enqueue(
|
enqueue(
|
||||||
start_merge,
|
start_merge,
|
||||||
queue="default",
|
queue="default",
|
||||||
timeout=6000,
|
timeout=6000,
|
||||||
event="ledger_merge",
|
event="ledger_merge",
|
||||||
job_name=self.name,
|
job_id=job_id,
|
||||||
docname=self.name,
|
docname=self.name,
|
||||||
now=frappe.conf.developer_mode or frappe.flags.in_test,
|
now=frappe.conf.developer_mode or frappe.flags.in_test,
|
||||||
)
|
)
|
||||||
|
@ -6,7 +6,7 @@ import frappe
|
|||||||
from frappe import _, scrub
|
from frappe import _, scrub
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.utils import flt, nowdate
|
from frappe.utils import flt, nowdate
|
||||||
from frappe.utils.background_jobs import enqueue, is_job_queued
|
from frappe.utils.background_jobs import enqueue, is_job_enqueued
|
||||||
|
|
||||||
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
|
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
|
||||||
get_accounting_dimensions,
|
get_accounting_dimensions,
|
||||||
@ -212,13 +212,15 @@ class OpeningInvoiceCreationTool(Document):
|
|||||||
if is_scheduler_inactive() and not frappe.flags.in_test:
|
if is_scheduler_inactive() and not frappe.flags.in_test:
|
||||||
frappe.throw(_("Scheduler is inactive. Cannot import data."), title=_("Scheduler Inactive"))
|
frappe.throw(_("Scheduler is inactive. Cannot import data."), title=_("Scheduler Inactive"))
|
||||||
|
|
||||||
if not is_job_queued(self.name):
|
job_id = f"opening_invoice::{self.name}"
|
||||||
|
|
||||||
|
if not is_job_enqueued(job_id):
|
||||||
enqueue(
|
enqueue(
|
||||||
start_import,
|
start_import,
|
||||||
queue="default",
|
queue="default",
|
||||||
timeout=6000,
|
timeout=6000,
|
||||||
event="opening_invoice_creation",
|
event="opening_invoice_creation",
|
||||||
job_name=self.name,
|
job_id=job_id,
|
||||||
invoices=invoices,
|
invoices=invoices,
|
||||||
now=frappe.conf.developer_mode or frappe.flags.in_test,
|
now=frappe.conf.developer_mode or frappe.flags.in_test,
|
||||||
)
|
)
|
||||||
|
@ -9,7 +9,7 @@ from frappe import _
|
|||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.model.mapper import map_child_doc, map_doc
|
from frappe.model.mapper import map_child_doc, map_doc
|
||||||
from frappe.utils import cint, flt, get_time, getdate, nowdate, nowtime
|
from frappe.utils import cint, flt, get_time, getdate, nowdate, nowtime
|
||||||
from frappe.utils.background_jobs import enqueue, is_job_queued
|
from frappe.utils.background_jobs import enqueue, is_job_enqueued
|
||||||
from frappe.utils.scheduler import is_scheduler_inactive
|
from frappe.utils.scheduler import is_scheduler_inactive
|
||||||
|
|
||||||
|
|
||||||
@ -483,15 +483,15 @@ def enqueue_job(job, **kwargs):
|
|||||||
|
|
||||||
closing_entry = kwargs.get("closing_entry") or {}
|
closing_entry = kwargs.get("closing_entry") or {}
|
||||||
|
|
||||||
job_name = closing_entry.get("name")
|
job_id = "pos_invoice_merge::" + str(closing_entry.get("name"))
|
||||||
if not is_job_queued(job_name):
|
if not is_job_enqueued(job_id):
|
||||||
enqueue(
|
enqueue(
|
||||||
job,
|
job,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
queue="long",
|
queue="long",
|
||||||
timeout=10000,
|
timeout=10000,
|
||||||
event="processing_merge_logs",
|
event="processing_merge_logs",
|
||||||
job_name=job_name,
|
job_id=job_id,
|
||||||
now=frappe.conf.developer_mode or frappe.flags.in_test
|
now=frappe.conf.developer_mode or frappe.flags.in_test
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user