fix(setup): use frappe.enqueue with enqueue_after_commit=True #137

Merged
tant merged 1 commit from fix/wizard-enqueue-api-correct into develop 2026-05-13 13:50:12 +07:00
Owner
No description provided.
c5d1359 called frappe.enqueue_after_commit() which does not exist in
Frappe v16 — that API is exposed only as a kwarg of frappe.enqueue().
Result: AttributeError fires inside Company.after_insert, which runs
inside the setup wizard's savepoint, so the wizard rolls back the
Company insert entirely while still flipping setup_complete=1. The
site ends up with the same "empty Company list, wizard locked" state
the original PR #136 was meant to prevent.

Switch to the supported signature:

    frappe.enqueue(
        "vhrms.vhrms.setup._per_company",
        queue="default",
        timeout=600,
        enqueue_after_commit=True,
        company=doc.name,
    )

Verified via Frappe source:
frappe/utils/background_jobs.py:76-206 — enqueue() accepts
enqueue_after_commit; when True it registers via frappe.db.after_commit
so the per-company job runs only after the wizard transaction commits,
preserving the original race-condition fix from c5d1359.
tant merged commit 1be10b1d40 into develop 2026-05-13 13:50:12 +07:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
tant/vhrms!137
No description provided.