mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-31 02:20:48 +02:00
fix: production plan bom error (#43591)
(cherry picked from commit ab171326f3)
Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
@@ -277,7 +277,7 @@ frappe.ui.form.on("Production Plan", {
|
|||||||
frm.clear_table("prod_plan_references");
|
frm.clear_table("prod_plan_references");
|
||||||
|
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "get_items",
|
method: "combine_so_items",
|
||||||
freeze: true,
|
freeze: true,
|
||||||
doc: frm.doc,
|
doc: frm.doc,
|
||||||
callback: function () {
|
callback: function () {
|
||||||
|
|||||||
@@ -269,6 +269,31 @@ class ProductionPlan(Document):
|
|||||||
{"material_request": data.name, "material_request_date": data.transaction_date},
|
{"material_request": data.name, "material_request_date": data.transaction_date},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def combine_so_items(self):
|
||||||
|
if self.combine_items and self.po_items and len(self.po_items) > 0:
|
||||||
|
items = []
|
||||||
|
for row in self.po_items:
|
||||||
|
items.append(
|
||||||
|
frappe._dict(
|
||||||
|
{
|
||||||
|
"parent": row.sales_order,
|
||||||
|
"item_code": row.item_code,
|
||||||
|
"warehouse": row.warehouse,
|
||||||
|
"qty": row.pending_qty,
|
||||||
|
"pending_qty": row.pending_qty,
|
||||||
|
"conversion_factor": 1.0,
|
||||||
|
"description": row.description,
|
||||||
|
"bom_no": row.bom_no,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
self.set("po_items", [])
|
||||||
|
self.add_items(items)
|
||||||
|
else:
|
||||||
|
self.get_items()
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_items(self):
|
def get_items(self):
|
||||||
self.set("po_items", [])
|
self.set("po_items", [])
|
||||||
@@ -435,24 +460,28 @@ class ProductionPlan(Document):
|
|||||||
|
|
||||||
item_details = get_item_details(data.item_code, throw=False)
|
item_details = get_item_details(data.item_code, throw=False)
|
||||||
if self.combine_items:
|
if self.combine_items:
|
||||||
if item_details.bom_no in refs:
|
bom_no = item_details.bom_no
|
||||||
refs[item_details.bom_no]["so_details"].append(
|
if data.get("bom_no"):
|
||||||
|
bom_no = data.get("bom_no")
|
||||||
|
|
||||||
|
if bom_no in refs:
|
||||||
|
refs[bom_no]["so_details"].append(
|
||||||
{"sales_order": data.parent, "sales_order_item": data.name, "qty": data.pending_qty}
|
{"sales_order": data.parent, "sales_order_item": data.name, "qty": data.pending_qty}
|
||||||
)
|
)
|
||||||
refs[item_details.bom_no]["qty"] += data.pending_qty
|
refs[bom_no]["qty"] += data.pending_qty
|
||||||
continue
|
continue
|
||||||
|
|
||||||
else:
|
else:
|
||||||
refs[item_details.bom_no] = {
|
refs[bom_no] = {
|
||||||
"qty": data.pending_qty,
|
"qty": data.pending_qty,
|
||||||
"po_item_ref": data.name,
|
"po_item_ref": data.name,
|
||||||
"so_details": [],
|
"so_details": [],
|
||||||
}
|
}
|
||||||
refs[item_details.bom_no]["so_details"].append(
|
refs[bom_no]["so_details"].append(
|
||||||
{"sales_order": data.parent, "sales_order_item": data.name, "qty": data.pending_qty}
|
{"sales_order": data.parent, "sales_order_item": data.name, "qty": data.pending_qty}
|
||||||
)
|
)
|
||||||
|
|
||||||
bom_no = data.bom_no or item_details and item_details.bom_no or ""
|
bom_no = data.bom_no or item_details and item_details.get("bom_no") or ""
|
||||||
if not bom_no:
|
if not bom_no:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user