fix: Added Item Reference field to link tables and update work_order_qty
diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.py b/erpnext/manufacturing/doctype/production_plan/production_plan.py
index b2bc21f..088089f 100644
--- a/erpnext/manufacturing/doctype/production_plan/production_plan.py
+++ b/erpnext/manufacturing/doctype/production_plan/production_plan.py
@@ -201,6 +201,7 @@
pi.sales_order = data.parent
pi.sales_order_item = data.name
pi.description = data.description
+ pi.item_reference = data.name
elif self.get_items_from == "Material Request":
diff --git a/erpnext/manufacturing/doctype/production_plan_item/production_plan_item.json b/erpnext/manufacturing/doctype/production_plan_item/production_plan_item.json
index 9ff1717..89ab7aa 100644
--- a/erpnext/manufacturing/doctype/production_plan_item/production_plan_item.json
+++ b/erpnext/manufacturing/doctype/production_plan_item/production_plan_item.json
@@ -27,7 +27,8 @@
"column_break_19",
"material_request",
"material_request_item",
- "product_bundle_item"
+ "product_bundle_item",
+ "item_reference"
],
"fields": [
{
@@ -206,12 +207,18 @@
"options": "Item",
"print_hide": 1,
"read_only": 1
+ },
+ {
+ "fieldname": "item_reference",
+ "fieldtype": "Data",
+ "hidden": 1,
+ "label": "Item Reference"
}
],
"idx": 1,
"istable": 1,
"links": [],
- "modified": "2021-04-22 12:10:01.102440",
+ "modified": "2021-04-28 19:14:57.772123",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Production Plan Item",
diff --git a/erpnext/manufacturing/doctype/work_order/work_order.py b/erpnext/manufacturing/doctype/work_order/work_order.py
index 87d57ad..d77c46f 100644
--- a/erpnext/manufacturing/doctype/work_order/work_order.py
+++ b/erpnext/manufacturing/doctype/work_order/work_order.py
@@ -382,8 +382,10 @@
prod_plan = frappe.get_doc('Production Plan', self.production_plan)
pp_ref = prod_plan.prod_plan_ref
+ pp_item = frappe.get_doc('Production Plan Item', self.production_plan_item)
+ item_ref = pp_item.item_reference
for p in pp_ref:
- if p.item_ref == self.production_plan_item:
+ if p.item_ref == item_ref:
work_order_qty = int(p.qty) if not cancel else 0
frappe.db.set_value('Sales Order Item',
p.sales_order_item, 'work_order_qty', flt(work_order_qty/total_bundle_qty, 2))