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:
for_quantity == total_completed_qty and process_loss_qty == 0
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
- Create or open a Work Order with operations.
- Open a Job Card for one operation.
- Add time logs and complete the full quantity.
- Submit the Job Card.
- 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.
Information about bug
Submitted Job Cards can remain in status
Work In Progresseven when the saved document values indicate they should beCompleted.Observed on ERPNext v16 in Manufacturing > Job Card.
This happens in at least these scenarios:
for_quantity == total_completed_qtyandprocess_loss_qty == 0total_completed_qty + process_loss_qty == for_quantityIn both cases, the Job Card is submitted (
docstatus = 1) but the persistedstatusremainsWork In Progress.Examples observed
Example 1
PO-JOB00136docstatus = 1for_quantity = 20total_completed_qty = 20process_loss_qty = 0status = "Work In Progress"This Job Card should be
Completed.Example 2
PO-JOB00153docstatus = 1for_quantity = 60total_completed_qty = 60process_loss_qty = 0status = "Work In Progress"This Job Card should also be
Completed.Example 3
PO-JOB00142docstatus = 1for_quantity = 60total_completed_qty = 20process_loss_qty = 40status = "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
statusshould be recalculated and persisted correctly.Expected:
docstatus = 1andfor_quantity <= total_completed_qty + process_loss_qty, status should beCompletedSteps to reproduce
In affected cases:
total_completed_qtyis saved correctlystatusstill remainsWork In ProgressTechnical observation
In
erpnext/manufacturing/doctype/job_card/job_card.py,set_status()already contains the correct completion rule.However, the final persisted
statuscan 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
statusis stored intabJob Cardand is reflected in list view as well.Possible root cause
A likely cause is that
statusis being calculated before the final values of:total_completed_qtyprocess_loss_qtyare 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:
self.set_status()again after the final header values are in placeself.set_status(update_status=True)For already affected submitted Job Cards, a repair helper also worked by:
Job Card Time Log/Job Card Operationtotal_completed_qtyandprocess_loss_qtyset_status(update_status=True)againSo 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.