mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-14 12:25:09 +00:00
chore: make job card employee field read only
This commit is contained in:
@@ -405,7 +405,8 @@
|
||||
"fieldname": "employee",
|
||||
"fieldtype": "Table MultiSelect",
|
||||
"label": "Employee",
|
||||
"options": "Job Card Time Log"
|
||||
"options": "Job Card Time Log",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "serial_no",
|
||||
@@ -625,7 +626,7 @@
|
||||
"grid_page_length": 50,
|
||||
"is_submittable": 1,
|
||||
"links": [],
|
||||
"modified": "2025-08-04 15:47:54.514290",
|
||||
"modified": "2025-12-22 14:20:07.817118",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Manufacturing",
|
||||
"name": "Job Card",
|
||||
|
||||
@@ -162,6 +162,7 @@ class JobCard(Document):
|
||||
self.set_total_completed_qty_from_sub_operations()
|
||||
|
||||
self.validate_work_order()
|
||||
self.set_employees()
|
||||
|
||||
def on_update(self):
|
||||
self.validate_job_card_qty()
|
||||
@@ -611,11 +612,6 @@ class JobCard(Document):
|
||||
row = self.append("time_logs", args)
|
||||
row.db_update()
|
||||
|
||||
def set_employees(self, employees):
|
||||
for name in employees:
|
||||
self.append("employee", {"employee": name.get("employee"), "completed_qty": 0.0})
|
||||
self.save()
|
||||
|
||||
def update_sub_operation_status(self):
|
||||
if not self.sub_operations:
|
||||
return
|
||||
@@ -1210,6 +1206,12 @@ class JobCard(Document):
|
||||
if self.is_work_order_closed():
|
||||
frappe.throw(_("You can't make any changes to Job Card since Work Order is closed."))
|
||||
|
||||
def set_employees(self):
|
||||
self.employee = []
|
||||
for item in self.time_logs:
|
||||
if not any(d.employee == item.employee for d in self.employee):
|
||||
self.append("employee", {"employee": item.employee, "completed_qty": 0.0})
|
||||
|
||||
def is_work_order_closed(self):
|
||||
if self.work_order:
|
||||
status = frappe.get_value("Work Order", self.work_order)
|
||||
@@ -1265,10 +1267,8 @@ class JobCard(Document):
|
||||
|
||||
self.set_status(update_status=update_status)
|
||||
|
||||
if not self.employee and kwargs.employees:
|
||||
self.set_employees(kwargs.employees)
|
||||
|
||||
self.validate_time_logs(save=True)
|
||||
self.save()
|
||||
|
||||
def update_workstation_status(self):
|
||||
status_map = {
|
||||
@@ -1309,17 +1309,15 @@ class JobCard(Document):
|
||||
kwargs = frappe._dict(kwargs)
|
||||
|
||||
if kwargs.end_time:
|
||||
if kwargs.for_quantity:
|
||||
self.for_quantity = kwargs.for_quantity
|
||||
|
||||
self.add_time_logs(
|
||||
to_time=kwargs.end_time,
|
||||
completed_qty=kwargs.qty,
|
||||
employees=self.employee,
|
||||
sub_operation=kwargs.get("sub_operation"),
|
||||
)
|
||||
|
||||
if kwargs.for_quantity:
|
||||
self.for_quantity = kwargs.for_quantity
|
||||
|
||||
self.save()
|
||||
else:
|
||||
self.add_time_logs(completed_qty=kwargs.qty, employees=self.employee)
|
||||
self.save()
|
||||
|
||||
Reference in New Issue
Block a user