mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-04 14:08:29 +00:00
Merge pull request #49255 from rohitwaghchaure/fixed-github-49034
fix: sub-operation not working
This commit is contained in:
@@ -31,6 +31,16 @@ frappe.ui.form.on("Job Card", {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
frm.set_query("operation", "time_logs", () => {
|
||||||
|
let operations = (frm.doc.sub_operations || []).map((d) => d.sub_operation);
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
name: ["in", operations],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
frm.events.set_company_filters(frm, "target_warehouse");
|
||||||
frm.events.set_company_filters(frm, "source_warehouse");
|
frm.events.set_company_filters(frm, "source_warehouse");
|
||||||
frm.events.set_company_filters(frm, "wip_warehouse");
|
frm.events.set_company_filters(frm, "wip_warehouse");
|
||||||
frm.set_query("source_warehouse", "items", () => {
|
frm.set_query("source_warehouse", "items", () => {
|
||||||
@@ -184,7 +194,12 @@ frappe.ui.form.on("Job Card", {
|
|||||||
!frm.doc.finished_good ||
|
!frm.doc.finished_good ||
|
||||||
!has_items?.length)
|
!has_items?.length)
|
||||||
) {
|
) {
|
||||||
if (!frm.doc.time_logs?.length) {
|
let last_row = {};
|
||||||
|
if (frm.doc.sub_operations?.length && frm.doc.time_logs?.length) {
|
||||||
|
last_row = get_last_row(frm.doc.time_logs);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!frm.doc.time_logs?.length || (frm.doc.sub_operations?.length && last_row?.to_time)) {
|
||||||
frm.add_custom_button(__("Start Job"), () => {
|
frm.add_custom_button(__("Start Job"), () => {
|
||||||
let from_time = frappe.datetime.now_datetime();
|
let from_time = frappe.datetime.now_datetime();
|
||||||
if ((frm.doc.employee && !frm.doc.employee.length) || !frm.doc.employee) {
|
if ((frm.doc.employee && !frm.doc.employee.length) || !frm.doc.employee) {
|
||||||
@@ -313,7 +328,12 @@ frappe.ui.form.on("Job Card", {
|
|||||||
];
|
];
|
||||||
|
|
||||||
let last_completed_row = get_last_completed_row(frm.doc.time_logs);
|
let last_completed_row = get_last_completed_row(frm.doc.time_logs);
|
||||||
if (!last_completed_row || !last_completed_row.to_time) {
|
let last_row = {};
|
||||||
|
if (frm.doc.sub_operations?.length && frm.doc.time_logs?.length) {
|
||||||
|
last_row = get_last_row(frm.doc.time_logs);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!last_completed_row || !last_completed_row.to_time || !last_row.to_time) {
|
||||||
fields.push({
|
fields.push({
|
||||||
fieldtype: "Datetime",
|
fieldtype: "Datetime",
|
||||||
label: __("End Time"),
|
label: __("End Time"),
|
||||||
@@ -758,3 +778,7 @@ function get_last_completed_row(time_logs) {
|
|||||||
return last_completed_row;
|
return last_completed_row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_last_row(time_logs) {
|
||||||
|
return time_logs[time_logs.length - 1] || {};
|
||||||
|
}
|
||||||
|
|||||||
@@ -157,6 +157,9 @@ class JobCard(Document):
|
|||||||
self.validate_sequence_id()
|
self.validate_sequence_id()
|
||||||
self.set_sub_operations()
|
self.set_sub_operations()
|
||||||
self.update_sub_operation_status()
|
self.update_sub_operation_status()
|
||||||
|
if self.sub_operations:
|
||||||
|
self.set_total_completed_qty_from_sub_operations()
|
||||||
|
|
||||||
self.validate_work_order()
|
self.validate_work_order()
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
@@ -280,8 +283,13 @@ class JobCard(Document):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def set_total_completed_qty_from_sub_operations(self):
|
||||||
|
sub_op_total_qty = []
|
||||||
for row in self.sub_operations:
|
for row in self.sub_operations:
|
||||||
self.total_completed_qty += row.completed_qty
|
sub_op_total_qty.append(flt(row.completed_qty))
|
||||||
|
|
||||||
|
if sub_op_total_qty:
|
||||||
|
self.total_completed_qty = min(sub_op_total_qty)
|
||||||
|
|
||||||
def get_overlap_for(self, args, open_job_cards=None):
|
def get_overlap_for(self, args, open_job_cards=None):
|
||||||
time_logs = []
|
time_logs = []
|
||||||
@@ -613,7 +621,7 @@ class JobCard(Document):
|
|||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
def update_sub_operation_status(self):
|
def update_sub_operation_status(self):
|
||||||
if not (self.sub_operations and self.time_logs):
|
if not self.sub_operations:
|
||||||
return
|
return
|
||||||
|
|
||||||
operation_wise_completed_time = {}
|
operation_wise_completed_time = {}
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
"field_order": [
|
"field_order": [
|
||||||
"sub_operation",
|
"sub_operation",
|
||||||
|
"completed_qty",
|
||||||
"completed_time",
|
"completed_time",
|
||||||
"status",
|
"status"
|
||||||
"completed_qty"
|
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
@@ -39,6 +39,7 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "completed_qty",
|
"fieldname": "completed_qty",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
|
"in_list_view": 1,
|
||||||
"label": "Completed Qty",
|
"label": "Completed Qty",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
}
|
}
|
||||||
@@ -46,15 +47,16 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-03-27 13:09:57.090298",
|
"modified": "2025-08-20 21:44:43.941434",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "Job Card Operation",
|
"name": "Job Card Operation",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [],
|
"permissions": [],
|
||||||
"quick_entry": 1,
|
"quick_entry": 1,
|
||||||
|
"row_format": "Dynamic",
|
||||||
"sort_field": "creation",
|
"sort_field": "creation",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"states": [],
|
"states": [],
|
||||||
"track_changes": 1
|
"track_changes": 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"allow_on_submit": 1,
|
"allow_on_submit": 1,
|
||||||
|
"columns": 3,
|
||||||
"fieldname": "from_time",
|
"fieldname": "from_time",
|
||||||
"fieldtype": "Datetime",
|
"fieldtype": "Datetime",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
@@ -58,17 +59,17 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "operation",
|
"fieldname": "operation",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Operation",
|
"in_list_view": 1,
|
||||||
|
"label": "Sub Operation",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"options": "Operation",
|
"options": "Operation"
|
||||||
"read_only": 1
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"grid_page_length": 50,
|
"grid_page_length": 50,
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2025-08-04 15:47:11.748937",
|
"modified": "2025-08-20 21:49:59.084876",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "Job Card Time Log",
|
"name": "Job Card Time Log",
|
||||||
|
|||||||
Reference in New Issue
Block a user