fix: inspection type when create a qc from dc

This commit is contained in:
Nihantra Patel
2024-04-15 17:46:21 +05:30
parent 760e341cd0
commit 098b62f0f6
3 changed files with 11 additions and 4 deletions

View File

@@ -1361,7 +1361,7 @@ def repost_required_for_queue(doc: StockController) -> bool:
@frappe.whitelist() @frappe.whitelist()
def make_quality_inspections(doctype, docname, items): def make_quality_inspections(doctype, docname, items, inspection_type):
if isinstance(items, str): if isinstance(items, str):
items = json.loads(items) items = json.loads(items)
@@ -1381,7 +1381,7 @@ def make_quality_inspections(doctype, docname, items):
quality_inspection = frappe.get_doc( quality_inspection = frappe.get_doc(
{ {
"doctype": "Quality Inspection", "doctype": "Quality Inspection",
"inspection_type": "Incoming", "inspection_type": inspection_type,
"inspected_by": frappe.session.user, "inspected_by": frappe.session.user,
"reference_type": doctype, "reference_type": doctype,
"reference_name": docname, "reference_name": docname,

View File

@@ -2203,6 +2203,8 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
]; ];
const me = this; const me = this;
const inspection_type = ["Purchase Receipt", "Purchase Invoice", "Subcontracting Receipt"].includes(this.frm.doc.doctype)
? "Incoming" : "Outgoing";
const dialog = new frappe.ui.Dialog({ const dialog = new frappe.ui.Dialog({
title: __("Select Items for Quality Inspection"), title: __("Select Items for Quality Inspection"),
size: "extra-large", size: "extra-large",
@@ -2214,7 +2216,8 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
args: { args: {
doctype: me.frm.doc.doctype, doctype: me.frm.doc.doctype,
docname: me.frm.doc.name, docname: me.frm.doc.name,
items: data.items items: data.items,
inspection_type: inspection_type
}, },
freeze: true, freeze: true,
callback: function (r) { callback: function (r) {

View File

@@ -138,9 +138,13 @@ class TestQualityInspection(FrappeTestCase):
def test_make_quality_inspections_from_linked_document(self): def test_make_quality_inspections_from_linked_document(self):
dn = create_delivery_note(item_code="_Test Item with QA", do_not_submit=True) dn = create_delivery_note(item_code="_Test Item with QA", do_not_submit=True)
if dn.doctype in ["Purchase Receipt", "Purchase Invoice", "Subcontracting Receipt"]:
inspection_type = "Incoming"
else:
inspection_type = "Outgoing"
for item in dn.items: for item in dn.items:
item.sample_size = item.qty item.sample_size = item.qty
quality_inspections = make_quality_inspections(dn.doctype, dn.name, dn.items) quality_inspections = make_quality_inspections(dn.doctype, dn.name, dn.items, inspection_type)
self.assertEqual(len(dn.items), len(quality_inspections)) self.assertEqual(len(dn.items), len(quality_inspections))
# cleanup # cleanup