mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-15 15:38:39 +00:00
refactor: drop unused operation_row_number field from Job Card
This commit is contained in:
@@ -172,8 +172,6 @@ frappe.ui.form.on("Job Card", {
|
||||
},
|
||||
}));
|
||||
|
||||
frm.trigger("toggle_operation_number");
|
||||
|
||||
const is_timer_running = frm.events.setup_job_action_buttons(frm, has_items);
|
||||
|
||||
if (!is_timer_running) {
|
||||
@@ -498,8 +496,6 @@ frappe.ui.form.on("Job Card", {
|
||||
},
|
||||
|
||||
operation(frm) {
|
||||
frm.trigger("toggle_operation_number");
|
||||
|
||||
if (frm.doc.operation && frm.doc.work_order) {
|
||||
frappe.call({
|
||||
method: "erpnext.manufacturing.doctype.job_card.job_card.get_operation_details",
|
||||
@@ -508,37 +504,14 @@ frappe.ui.form.on("Job Card", {
|
||||
operation: frm.doc.operation,
|
||||
},
|
||||
callback(r) {
|
||||
if (!r.message) return;
|
||||
|
||||
if (r.message.length == 1) {
|
||||
if (r.message && r.message.length == 1) {
|
||||
frm.set_value("operation_id", r.message[0].name);
|
||||
} else {
|
||||
const args = r.message.map((row) => ({ label: row.idx, value: row.name }));
|
||||
const description = __("Operation {0} added multiple times in the work order {1}", [
|
||||
frm.doc.operation,
|
||||
frm.doc.work_order,
|
||||
]);
|
||||
frm.set_df_property("operation_row_number", "options", args);
|
||||
frm.set_df_property("operation_row_number", "description", description);
|
||||
}
|
||||
|
||||
frm.trigger("toggle_operation_number");
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
operation_row_number(frm) {
|
||||
if (frm.doc.operation_row_number) {
|
||||
frm.set_value("operation_id", frm.doc.operation_row_number);
|
||||
}
|
||||
},
|
||||
|
||||
toggle_operation_number(frm) {
|
||||
frm.toggle_display("operation_row_number", !frm.doc.operation_id && frm.doc.operation);
|
||||
frm.toggle_reqd("operation_row_number", !frm.doc.operation_id && frm.doc.operation);
|
||||
},
|
||||
|
||||
make_time_log(frm, args) {
|
||||
frm.events.update_sub_operation(frm, args);
|
||||
|
||||
|
||||
@@ -92,7 +92,6 @@
|
||||
"operation_row_id",
|
||||
"amended_from",
|
||||
"column_break_xhzg",
|
||||
"operation_row_number",
|
||||
"operation_id",
|
||||
"sequence_id",
|
||||
"section_break_jcmx",
|
||||
@@ -324,11 +323,6 @@
|
||||
"label": "Item Name",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "operation_row_number",
|
||||
"fieldtype": "Select",
|
||||
"label": "Operation Row Number"
|
||||
},
|
||||
{
|
||||
"fieldname": "sequence_id",
|
||||
"fieldtype": "Int",
|
||||
@@ -695,7 +689,7 @@
|
||||
"grid_page_length": 50,
|
||||
"is_submittable": 1,
|
||||
"links": [],
|
||||
"modified": "2026-06-20 17:39:42.293242",
|
||||
"modified": "2026-07-23 12:00:00.000000",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Manufacturing",
|
||||
"name": "Job Card",
|
||||
|
||||
@@ -45,10 +45,6 @@ class OverlapError(frappe.ValidationError):
|
||||
pass
|
||||
|
||||
|
||||
class OperationMismatchError(frappe.ValidationError):
|
||||
pass
|
||||
|
||||
|
||||
class OperationSequenceError(frappe.ValidationError):
|
||||
pass
|
||||
|
||||
@@ -106,7 +102,6 @@ class JobCard(Document):
|
||||
operation: DF.Link
|
||||
operation_id: DF.Data | None
|
||||
operation_row_id: DF.Int
|
||||
operation_row_number: DF.Literal[None]
|
||||
pending_qty: DF.Float
|
||||
posting_date: DF.Date | None
|
||||
process_loss_qty: DF.Float
|
||||
@@ -168,7 +163,6 @@ class JobCard(Document):
|
||||
self.validate_time_logs()
|
||||
self.validate_on_hold()
|
||||
self.set_status()
|
||||
self.validate_operation_id()
|
||||
self.validate_sequence_id()
|
||||
self.set_sub_operations()
|
||||
self.update_sub_operation_status()
|
||||
@@ -1344,23 +1338,6 @@ class JobCard(Document):
|
||||
if not self.wip_warehouse:
|
||||
self.wip_warehouse = frappe.get_cached_value("Company", self.company, "default_wip_warehouse")
|
||||
|
||||
def validate_operation_id(self):
|
||||
if (
|
||||
self.get("operation_id")
|
||||
and self.get("operation_row_number")
|
||||
and self.operation
|
||||
and self.work_order
|
||||
and frappe.get_cached_value("Work Order Operation", self.operation_row_number, "name")
|
||||
!= self.operation_id
|
||||
):
|
||||
work_order = bold(get_link_to_form("Work Order", self.work_order))
|
||||
frappe.throw(
|
||||
_("Operation {0} does not belong to the work order {1}").format(
|
||||
bold(self.operation), work_order
|
||||
),
|
||||
OperationMismatchError,
|
||||
)
|
||||
|
||||
@frappe.whitelist()
|
||||
def pause_job(self, **kwargs):
|
||||
frappe.has_permission("Job Card", "write", doc=self, throw=True)
|
||||
|
||||
@@ -10,7 +10,6 @@ from frappe.utils.data import add_to_date, now, today
|
||||
|
||||
from erpnext.manufacturing.doctype.job_card.job_card import (
|
||||
JobCardOverTransferError,
|
||||
OperationMismatchError,
|
||||
OverlapError,
|
||||
)
|
||||
from erpnext.manufacturing.doctype.job_card.mapper import (
|
||||
@@ -149,19 +148,6 @@ class TestJobCard(ERPNextTestSuite):
|
||||
)
|
||||
self.assertRaises(frappe.ValidationError, job_card_doc.submit)
|
||||
|
||||
def test_job_card_operations(self):
|
||||
job_cards = frappe.get_all(
|
||||
"Job Card", filters={"work_order": self.work_order.name}, fields=["operation_id", "name"]
|
||||
)
|
||||
|
||||
if job_cards:
|
||||
job_card = job_cards[0]
|
||||
frappe.db.set_value("Job Card", job_card.name, "operation_row_number", job_card.operation_id)
|
||||
|
||||
doc = frappe.get_doc("Job Card", job_card.name)
|
||||
doc.operation_id = "Test Data"
|
||||
self.assertRaises(OperationMismatchError, doc.save)
|
||||
|
||||
def test_job_card_with_different_work_station(self):
|
||||
job_cards = frappe.get_all(
|
||||
"Job Card",
|
||||
|
||||
Reference in New Issue
Block a user