fix: Added Item Reference field to link tables and update work_order_qty

This commit is contained in:
noahjacob
2021-04-28 19:21:36 +05:30
parent 82905166d9
commit b7ca913904
3 changed files with 13 additions and 3 deletions

View File

@@ -201,6 +201,7 @@ class ProductionPlan(Document):
pi.sales_order = data.parent pi.sales_order = data.parent
pi.sales_order_item = data.name pi.sales_order_item = data.name
pi.description = data.description pi.description = data.description
pi.item_reference = data.name
elif self.get_items_from == "Material Request": elif self.get_items_from == "Material Request":

View File

@@ -27,7 +27,8 @@
"column_break_19", "column_break_19",
"material_request", "material_request",
"material_request_item", "material_request_item",
"product_bundle_item" "product_bundle_item",
"item_reference"
], ],
"fields": [ "fields": [
{ {
@@ -206,12 +207,18 @@
"options": "Item", "options": "Item",
"print_hide": 1, "print_hide": 1,
"read_only": 1 "read_only": 1
},
{
"fieldname": "item_reference",
"fieldtype": "Data",
"hidden": 1,
"label": "Item Reference"
} }
], ],
"idx": 1, "idx": 1,
"istable": 1, "istable": 1,
"links": [], "links": [],
"modified": "2021-04-22 12:10:01.102440", "modified": "2021-04-28 19:14:57.772123",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Manufacturing", "module": "Manufacturing",
"name": "Production Plan Item", "name": "Production Plan Item",

View File

@@ -382,8 +382,10 @@ class WorkOrder(Document):
prod_plan = frappe.get_doc('Production Plan', self.production_plan) prod_plan = frappe.get_doc('Production Plan', self.production_plan)
pp_ref = prod_plan.prod_plan_ref 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: 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 work_order_qty = int(p.qty) if not cancel else 0
frappe.db.set_value('Sales Order Item', frappe.db.set_value('Sales Order Item',
p.sales_order_item, 'work_order_qty', flt(work_order_qty/total_bundle_qty, 2)) p.sales_order_item, 'work_order_qty', flt(work_order_qty/total_bundle_qty, 2))