fix: make stock entry in job card
This commit is contained in:
@@ -45,8 +45,7 @@ frappe.ui.form.on("Job Card", {
|
||||
|
||||
setup_stock_entry(frm) {
|
||||
if (
|
||||
frm.doc.manufactured_qty &&
|
||||
frm.doc.finished_good &&
|
||||
frm.doc.track_semi_finished_goods &&
|
||||
frm.doc.docstatus === 1 &&
|
||||
!frm.doc.is_subcontracted &&
|
||||
flt(frm.doc.for_quantity) + flt(frm.doc.process_loss_qty) > flt(frm.doc.manufactured_qty)
|
||||
@@ -252,7 +251,6 @@ frappe.ui.form.on("Job Card", {
|
||||
fieldtype: "Float",
|
||||
label: __("Process Loss Quantity"),
|
||||
fieldname: "process_loss_qty",
|
||||
reqd: 1,
|
||||
onchange() {
|
||||
let doc = frm.job_completion_dialog;
|
||||
|
||||
|
||||
@@ -241,7 +241,7 @@ class JobCard(Document):
|
||||
row.sub_operation = row.operation
|
||||
self.append("sub_operations", row)
|
||||
|
||||
def validate_time_logs(self):
|
||||
def validate_time_logs(self, save=False):
|
||||
self.total_time_in_mins = 0.0
|
||||
self.total_completed_qty = 0.0
|
||||
|
||||
@@ -272,6 +272,14 @@ class JobCard(Document):
|
||||
|
||||
self.total_completed_qty = flt(self.total_completed_qty, self.precision("total_completed_qty"))
|
||||
|
||||
if save and self.docstatus == 1:
|
||||
self.db_set(
|
||||
{
|
||||
"total_time_in_mins": self.total_time_in_mins,
|
||||
"total_completed_qty": self.total_completed_qty,
|
||||
}
|
||||
)
|
||||
|
||||
for row in self.sub_operations:
|
||||
self.total_completed_qty += row.completed_qty
|
||||
|
||||
@@ -670,7 +678,7 @@ class JobCard(Document):
|
||||
return
|
||||
|
||||
for d in doc.required_items:
|
||||
if not d.operation and not d.operation_row_id:
|
||||
if not doc.track_semi_finished_goods and not d.operation and not d.operation_row_id:
|
||||
frappe.throw(
|
||||
_("Row {0} : Operation is required against the raw material item {1}").format(
|
||||
d.idx, d.item_code
|
||||
@@ -1221,6 +1229,8 @@ class JobCard(Document):
|
||||
if not self.employee and kwargs.employees:
|
||||
self.set_employees(kwargs.employees)
|
||||
|
||||
self.validate_time_logs(save=True)
|
||||
|
||||
def update_workstation_status(self):
|
||||
status_map = {
|
||||
"Open": "Off",
|
||||
|
||||
Reference in New Issue
Block a user