mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-23 15:09:20 +00:00
fix: incorrect job card timer issue
This commit is contained in:
@@ -34,7 +34,7 @@ frappe.ui.form.on('Job Card', {
|
|||||||
frm.trigger("toggle_operation_number");
|
frm.trigger("toggle_operation_number");
|
||||||
|
|
||||||
if (frm.doc.docstatus == 0 && (frm.doc.for_quantity > frm.doc.total_completed_qty || !frm.doc.for_quantity)
|
if (frm.doc.docstatus == 0 && (frm.doc.for_quantity > frm.doc.total_completed_qty || !frm.doc.for_quantity)
|
||||||
&& (!frm.doc.items || !frm.doc.items.length || frm.doc.for_quantity == frm.doc.transferred_qty)) {
|
&& (frm.doc.items || !frm.doc.items.length || frm.doc.for_quantity == frm.doc.transferred_qty)) {
|
||||||
frm.trigger("prepare_timer_buttons");
|
frm.trigger("prepare_timer_buttons");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -94,9 +94,9 @@ frappe.ui.form.on('Job Card', {
|
|||||||
fieldname: 'employee'}, d => {
|
fieldname: 'employee'}, d => {
|
||||||
if (d.employee) {
|
if (d.employee) {
|
||||||
frm.set_value("employee", d.employee);
|
frm.set_value("employee", d.employee);
|
||||||
|
} else {
|
||||||
|
frm.events.start_job(frm);
|
||||||
}
|
}
|
||||||
|
|
||||||
frm.events.start_job(frm);
|
|
||||||
}, __("Enter Value"), __("Start"));
|
}, __("Enter Value"), __("Start"));
|
||||||
} else {
|
} else {
|
||||||
frm.events.start_job(frm);
|
frm.events.start_job(frm);
|
||||||
@@ -141,9 +141,7 @@ frappe.ui.form.on('Job Card', {
|
|||||||
frm.set_value('current_time' , 0);
|
frm.set_value('current_time' , 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
frm.save("Save", () => {}, "", () => {
|
frm.save();
|
||||||
frm.doc.time_logs.pop(-1);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
complete_job: function(frm, completed_time, completed_qty) {
|
complete_job: function(frm, completed_time, completed_qty) {
|
||||||
@@ -175,6 +173,8 @@ frappe.ui.form.on('Job Card', {
|
|||||||
employee: function(frm) {
|
employee: function(frm) {
|
||||||
if (frm.doc.job_started && !frm.doc.current_time) {
|
if (frm.doc.job_started && !frm.doc.current_time) {
|
||||||
frm.trigger("reset_timer");
|
frm.trigger("reset_timer");
|
||||||
|
} else {
|
||||||
|
frm.events.start_job(frm);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ class TestJobCard(unittest.TestCase):
|
|||||||
doc.operation_id = "Test Data"
|
doc.operation_id = "Test Data"
|
||||||
self.assertRaises(OperationMismatchError, doc.save)
|
self.assertRaises(OperationMismatchError, doc.save)
|
||||||
|
|
||||||
|
for d in job_cards:
|
||||||
|
frappe.delete_doc("Job Card", d.name)
|
||||||
|
|
||||||
def test_job_card_with_different_work_station(self):
|
def test_job_card_with_different_work_station(self):
|
||||||
data = frappe.get_cached_value('BOM',
|
data = frappe.get_cached_value('BOM',
|
||||||
{'docstatus': 1, 'with_operations': 1, 'company': '_Test Company'}, ['name', 'item'])
|
{'docstatus': 1, 'with_operations': 1, 'company': '_Test Company'}, ['name', 'item'])
|
||||||
@@ -40,9 +43,11 @@ class TestJobCard(unittest.TestCase):
|
|||||||
|
|
||||||
work_order = make_wo_order_test_record(item=bom_item, qty=1, bom_no=bom)
|
work_order = make_wo_order_test_record(item=bom_item, qty=1, bom_no=bom)
|
||||||
|
|
||||||
job_card = frappe.get_all('Job Card',
|
job_cards = frappe.get_all('Job Card',
|
||||||
filters = {'work_order': work_order.name},
|
filters = {'work_order': work_order.name},
|
||||||
fields = ["operation_id", "workstation", "name", "for_quantity"])[0]
|
fields = ["operation_id", "workstation", "name", "for_quantity"])
|
||||||
|
|
||||||
|
job_card = job_cards[0]
|
||||||
|
|
||||||
if job_card:
|
if job_card:
|
||||||
workstation = frappe.db.get_value("Workstation",
|
workstation = frappe.db.get_value("Workstation",
|
||||||
@@ -64,4 +69,7 @@ class TestJobCard(unittest.TestCase):
|
|||||||
completed_qty = frappe.db.get_value("Work Order Operation", job_card.operation_id, "completed_qty")
|
completed_qty = frappe.db.get_value("Work Order Operation", job_card.operation_id, "completed_qty")
|
||||||
self.assertEqual(completed_qty, job_card.for_quantity)
|
self.assertEqual(completed_qty, job_card.for_quantity)
|
||||||
|
|
||||||
doc.cancel()
|
doc.cancel()
|
||||||
|
|
||||||
|
for d in job_cards:
|
||||||
|
frappe.delete_doc("Job Card", d.name)
|
||||||
@@ -7,7 +7,7 @@ import unittest
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import flt, time_diff_in_hours, now, add_months, cint, today
|
from frappe.utils import flt, time_diff_in_hours, now, add_months, cint, today
|
||||||
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
|
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
|
||||||
from erpnext.manufacturing.doctype.work_order.work_order import (make_stock_entry,
|
from erpnext.manufacturing.doctype.work_order.work_order import (make_stock_entry,
|
||||||
ItemHasVariantError, stop_unstop, StockOverProductionError, OverProductionError, CapacityError)
|
ItemHasVariantError, stop_unstop, StockOverProductionError, OverProductionError, CapacityError)
|
||||||
from erpnext.stock.doctype.stock_entry import test_stock_entry
|
from erpnext.stock.doctype.stock_entry import test_stock_entry
|
||||||
from erpnext.stock.utils import get_bin
|
from erpnext.stock.utils import get_bin
|
||||||
|
|||||||
Reference in New Issue
Block a user