Merge pull request #21309 from rohitwaghchaure/fixed_job_card_time_issue_develop
fix: job card timer issue
This commit is contained in:
commit
e894c35b9a
@ -82,7 +82,9 @@ frappe.ui.form.on('Job Card', {
|
|||||||
frm.set_value('current_time' , 0);
|
frm.set_value('current_time' , 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
frm.save();
|
frm.save("Save", () => {}, "", () => {
|
||||||
|
frm.doc.time_logs.pop(-1);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
complete_job: function(frm, completed_time, completed_qty) {
|
complete_job: function(frm, completed_time, completed_qty) {
|
||||||
@ -105,6 +107,24 @@ frappe.ui.form.on('Job Card', {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
validate: function(frm) {
|
||||||
|
if ((!frm.doc.time_logs || !frm.doc.time_logs.length) && frm.doc.started_time) {
|
||||||
|
frm.trigger("reset_timer");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
employee: function(frm) {
|
||||||
|
if (frm.doc.job_started && !frm.doc.current_time) {
|
||||||
|
frm.trigger("reset_timer");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
reset_timer: function(frm) {
|
||||||
|
frm.set_value('started_time' , '');
|
||||||
|
frm.set_value('job_started', 0);
|
||||||
|
frm.set_value('current_time' , 0);
|
||||||
|
},
|
||||||
|
|
||||||
make_dashboard: function(frm) {
|
make_dashboard: function(frm) {
|
||||||
if(frm.doc.__islocal)
|
if(frm.doc.__islocal)
|
||||||
return;
|
return;
|
||||||
@ -205,5 +225,10 @@ frappe.ui.form.on('Job Card', {
|
|||||||
frappe.ui.form.on('Job Card Time Log', {
|
frappe.ui.form.on('Job Card Time Log', {
|
||||||
completed_qty: function(frm) {
|
completed_qty: function(frm) {
|
||||||
frm.events.set_total_completed_qty(frm);
|
frm.events.set_total_completed_qty(frm);
|
||||||
|
},
|
||||||
|
|
||||||
|
to_time: function(frm) {
|
||||||
|
frm.set_value('job_started', 0);
|
||||||
|
frm.set_value('started_time', '');
|
||||||
}
|
}
|
||||||
})
|
})
|
@ -9,7 +9,7 @@ from frappe import _
|
|||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.utils import (flt, cint, time_diff_in_hours, get_datetime, getdate,
|
from frappe.utils import (flt, cint, time_diff_in_hours, get_datetime, getdate,
|
||||||
get_time, add_to_date, time_diff, add_days, get_datetime_str)
|
get_time, add_to_date, time_diff, add_days, get_datetime_str, get_link_to_form)
|
||||||
|
|
||||||
from erpnext.manufacturing.doctype.manufacturing_settings.manufacturing_settings import get_mins_between_operations
|
from erpnext.manufacturing.doctype.manufacturing_settings.manufacturing_settings import get_mins_between_operations
|
||||||
|
|
||||||
@ -189,11 +189,15 @@ class JobCard(Document):
|
|||||||
|
|
||||||
def validate_job_card(self):
|
def validate_job_card(self):
|
||||||
if not self.time_logs:
|
if not self.time_logs:
|
||||||
frappe.throw(_("Time logs are required for job card {0}").format(self.name))
|
frappe.throw(_("Time logs are required for {0} {1}")
|
||||||
|
.format(frappe.bold("Job Card"), get_link_to_form("Job Card", self.name)))
|
||||||
|
|
||||||
if self.for_quantity and self.total_completed_qty != self.for_quantity:
|
if self.for_quantity and self.total_completed_qty != self.for_quantity:
|
||||||
frappe.throw(_("The total completed qty({0}) must be equal to qty to manufacture({1})"
|
total_completed_qty = frappe.bold(_("Total Completed Qty"))
|
||||||
.format(frappe.bold(self.total_completed_qty),frappe.bold(self.for_quantity))))
|
qty_to_manufacture = frappe.bold(_("Qty to Manufacture"))
|
||||||
|
|
||||||
|
frappe.throw(_("The {0} ({1}) must be equal to {2} ({3})"
|
||||||
|
.format(total_completed_qty, frappe.bold(self.total_completed_qty), qty_to_manufacture,frappe.bold(self.for_quantity))))
|
||||||
|
|
||||||
def update_work_order(self):
|
def update_work_order(self):
|
||||||
if not self.work_order:
|
if not self.work_order:
|
||||||
|
@ -240,6 +240,8 @@ frappe.ui.form.on("Work Order", {
|
|||||||
});
|
});
|
||||||
}, __("Job Card"), __("Create"));
|
}, __("Job Card"), __("Create"));
|
||||||
|
|
||||||
|
dialog.fields_dict["operations"].grid.wrapper.find('.grid-add-row').hide();
|
||||||
|
|
||||||
var pending_qty = 0;
|
var pending_qty = 0;
|
||||||
frm.doc.operations.forEach(data => {
|
frm.doc.operations.forEach(data => {
|
||||||
if(data.completed_qty != frm.doc.qty) {
|
if(data.completed_qty != frm.doc.qty) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user