Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(UX): use doc.status for Job Card status (backport #31320) #31321

Merged
merged 1 commit into from
Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions erpnext/manufacturing/doctype/job_card/job_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,14 +626,15 @@ def set_status(self, update_status=False):

self.status = {0: "Open", 1: "Submitted", 2: "Cancelled"}[self.docstatus or 0]

if self.for_quantity <= self.transferred_qty:
self.status = "Material Transferred"
if self.docstatus < 2:
if self.for_quantity <= self.transferred_qty:
self.status = "Material Transferred"

if self.time_logs:
self.status = "Work In Progress"
if self.time_logs:
self.status = "Work In Progress"

if self.docstatus == 1 and (self.for_quantity <= self.total_completed_qty or not self.items):
self.status = "Completed"
if self.docstatus == 1 and (self.for_quantity <= self.total_completed_qty or not self.items):
self.status = "Completed"

if update_status:
self.db_set("status", self.status)
Expand Down
23 changes: 12 additions & 11 deletions erpnext/manufacturing/doctype/job_card/job_card_list.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
frappe.listview_settings['Job Card'] = {
has_indicator_for_draft: true,

get_indicator: function(doc) {
if (doc.status === "Work In Progress") {
return [__("Work In Progress"), "orange", "status,=,Work In Progress"];
} else if (doc.status === "Completed") {
return [__("Completed"), "green", "status,=,Completed"];
} else if (doc.docstatus == 2) {
return [__("Cancelled"), "red", "status,=,Cancelled"];
} else if (doc.status === "Material Transferred") {
return [__('Material Transferred'), "blue", "status,=,Material Transferred"];
} else {
return [__("Open"), "red", "status,=,Open"];
}
const status_colors = {
"Work In Progress": "orange",
"Completed": "green",
"Cancelled": "red",
"Material Transferred": "blue",
"Open": "red",
};
const status = doc.status || "Open";
const color = status_colors[status] || "blue";

return [__(status), color, `status,=,${status}`];
}
};
25 changes: 25 additions & 0 deletions erpnext/manufacturing/doctype/job_card/test_job_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,31 @@ def test_corrective_costing(self):
cost_after_cancel = self.work_order.total_operating_cost
self.assertEqual(cost_after_cancel, original_cost)

def test_job_card_statuses(self):
def assertStatus(status):
jc.set_status()
self.assertEqual(jc.status, status)

jc = frappe.new_doc("Job Card")
jc.for_quantity = 2
jc.transferred_qty = 1
jc.total_completed_qty = 0
jc.time_logs = []
assertStatus("Open")

jc.transferred_qty = jc.for_quantity
assertStatus("Material Transferred")

jc.append("time_logs", {})
assertStatus("Work In Progress")

jc.docstatus = 1
jc.total_completed_qty = jc.for_quantity
assertStatus("Completed")

jc.docstatus = 2
assertStatus("Cancelled")


def create_bom_with_multiple_operations():
"Create a BOM with multiple operations and Material Transfer against Job Card"
Expand Down