Skip to content

Job Card stays "Work In Progress" after submit even when completed quantity equals qty to manufacture #54335

Description

@KunalAnabhavane

Information about bug

Submitted Job Cards can remain in status Work In Progress even when the saved document values indicate they should be Completed.

Observed on ERPNext v16 in Manufacturing > Job Card.

This happens in at least these scenarios:

  1. for_quantity == total_completed_qty and process_loss_qty == 0
  2. total_completed_qty + process_loss_qty == for_quantity

In both cases, the Job Card is submitted (docstatus = 1) but the persisted status remains Work In Progress.

Examples observed

Example 1

PO-JOB00136

  • docstatus = 1
  • for_quantity = 20
  • total_completed_qty = 20
  • process_loss_qty = 0
  • saved status = "Work In Progress"

This Job Card should be Completed.

Example 2

PO-JOB00153

  • docstatus = 1
  • for_quantity = 60
  • total_completed_qty = 60
  • process_loss_qty = 0
  • saved status = "Work In Progress"

This Job Card should also be Completed.

Example 3

PO-JOB00142

  • child rows contained valid completion data
  • final consistent state became:
    • docstatus = 1
    • for_quantity = 60
    • total_completed_qty = 20
    • process_loss_qty = 40
    • correct status = "Completed"

This shows the completion rule is consistent, but the persisted Job Card status can remain stale.

Expected behavior

When a Job Card is submitted, its final saved status should be recalculated and persisted correctly.

Expected:

  • if docstatus = 1 and for_quantity <= total_completed_qty + process_loss_qty, status should be Completed

Steps to reproduce

  1. Create or open a Work Order with operations.
  2. Open a Job Card for one operation.
  3. Add time logs and complete the full quantity.
  4. Submit the Job Card.
  5. Check the Job Card after submit.

In affected cases:

  • the Job Card is submitted successfully
  • total_completed_qty is saved correctly
  • but status still remains Work In Progress

Technical observation

In erpnext/manufacturing/doctype/job_card/job_card.py, set_status() already contains the correct completion rule.

However, the final persisted status can remain stale after submit even when the quantity fields are correct in the database.

This appears to be a server-side persistence issue, not only a UI issue, because the stale status is stored in tabJob Card and is reflected in list view as well.

Possible root cause

A likely cause is that status is being calculated before the final values of:

  • total_completed_qty
  • process_loss_qty

are fully settled and persisted during the submit flow.

Possible fix

A custom override fixed the issue on our side by recalculating the Job Card status again after ERPNext finishes its final quantity and process-loss updates.

The working approach was:

  • run the normal ERPNext save/submit flow first
  • then call self.set_status() again after the final header values are in place
  • and on submit explicitly persist it with self.set_status(update_status=True)

For already affected submitted Job Cards, a repair helper also worked by:

  • reading the saved child completion data from Job Card Time Log / Job Card Operation
  • resyncing header fields like total_completed_qty and process_loss_qty
  • then running set_status(update_status=True) again

So a likely core fix would be to ensure the final Job Card status is recalculated and written after the last quantity/process-loss update during submit.

Impact

This causes operational confusion in production because completed operations still appear active and users cannot rely on Job Card status in the UI.

Module

manufacturing

Version

Frappe version - 16.12.0
ERPNext version - 16.10.0

Installation method

None

Relevant log output / Stack trace / Full Error Message.

No server traceback is shown for this issue.

The issue is reproducible from saved database values:
- submitted Job Card (`docstatus = 1`)
- `for_quantity <= total_completed_qty + process_loss_qty`
- saved `status = "Work In Progress"`

Example observed:
PO-JOB00153
status = Work In Progress
for_quantity = 60
total_completed_qty = 60
process_loss_qty = 0

This should resolve to Completed according to the Job Card status logic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions