fix: job card time issue (#21306)

This commit is contained in:
rohitwaghchaure
2020-04-16 23:57:49 +05:30
committed by GitHub
parent a66be0f5c5
commit 61fc2d3263
3 changed files with 23 additions and 4 deletions

View File

@@ -109,6 +109,14 @@ frappe.ui.form.on('Job Card', {
});
},
validate: function(frm) {
if ((!frm.doc.time_logs || !frm.doc.time_logs.length) && frm.doc.started_time) {
frm.set_value('started_time' , '');
frm.set_value('job_started', 0);
frm.set_value('current_time' , 0);
}
},
make_dashboard: function(frm) {
if(frm.doc.__islocal)
return;
@@ -209,5 +217,10 @@ frappe.ui.form.on('Job Card', {
frappe.ui.form.on('Job Card Time Log', {
completed_qty: function(frm) {
frm.events.set_total_completed_qty(frm);
},
to_time: function(frm) {
frm.set_value('job_started', 0);
frm.set_value('started_time', '');
}
})

View File

@@ -5,7 +5,7 @@
from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.utils import flt, time_diff_in_hours, get_datetime, time_diff
from frappe.utils import flt, time_diff_in_hours, get_datetime, time_diff, get_link_to_form
from frappe.model.mapper import get_mapped_doc
from frappe.model.document import Document
@@ -90,11 +90,15 @@ class JobCard(Document):
def validate_job_card(self):
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:
frappe.throw(_("The total completed qty({0}) must be equal to qty to manufacture({1})"
.format(frappe.bold(self.total_completed_qty),frappe.bold(self.for_quantity))))
total_completed_qty = frappe.bold(_("Total Completed Qty"))
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):
if not self.work_order:

View File

@@ -232,6 +232,8 @@ frappe.ui.form.on("Work Order", {
});
}, __("Job Card"), __("Create"));
dialog.fields_dict["operations"].grid.wrapper.find('.grid-add-row').hide();
var pending_qty = 0;
frm.doc.operations.forEach(data => {
if(data.completed_qty != frm.doc.qty) {