From 3dfbf19e8f6ee97be7a1a727b98bfc0db1ec3db7 Mon Sep 17 00:00:00 2001 From: Frappe PR Bot Date: Mon, 9 Aug 2021 11:33:55 +0530 Subject: [PATCH] fix: allow alternative items when using job card (bp #26724) (cherry picked from commit 7e0c57fa3fe62417ad3be75412e0c031d6486bb8) Co-authored-by: Ankush --- erpnext/manufacturing/doctype/job_card/job_card.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/erpnext/manufacturing/doctype/job_card/job_card.py b/erpnext/manufacturing/doctype/job_card/job_card.py index 69c7f5c614..66e2394b84 100644 --- a/erpnext/manufacturing/doctype/job_card/job_card.py +++ b/erpnext/manufacturing/doctype/job_card/job_card.py @@ -608,6 +608,11 @@ def make_stock_entry(source_name, target_doc=None): target.set_missing_values() target.set_stock_entry_type() + wo_allows_alternate_item = frappe.db.get_value("Work Order", target.work_order, "allow_alternative_item") + for item in target.items: + item.allow_alternative_item = int(wo_allows_alternate_item and + frappe.get_cached_value("Item", item.item_code, "allow_alternative_item")) + doclist = get_mapped_doc("Job Card", source_name, { "Job Card": { "doctype": "Stock Entry", @@ -698,4 +703,4 @@ def make_corrective_job_card(source_name, operation=None, for_operation=None, ta } }, target_doc, set_missing_values) - return doclist \ No newline at end of file + return doclist