Merge pull request #45642 from rohitwaghchaure/fixed-support-30559

fix: actual qty showing blank for sub-assembly items
This commit is contained in:
rohitwaghchaure
2025-01-31 22:38:04 +05:30
committed by GitHub
2 changed files with 51 additions and 5 deletions

View File

@@ -562,6 +562,28 @@ frappe.ui.form.on("Production Plan Sales Order", {
frappe.ui.form.on("Production Plan Sub Assembly Item", {
fg_warehouse(frm, cdt, cdn) {
erpnext.utils.copy_value_in_all_rows(frm.doc, cdt, cdn, "sub_assembly_items", "fg_warehouse");
let row = locals[cdt][cdn];
if (row.fg_warehouse && row.production_item) {
let child_row = {
item_code: row.production_item,
warehouse: row.fg_warehouse,
};
frappe.call({
method: "erpnext.manufacturing.doctype.production_plan.production_plan.get_bin_details",
args: {
row: child_row,
company: frm.doc.company,
for_warehouse: row.fg_warehouse,
},
callback: function (r) {
if (r.message && r.message.length) {
frappe.model.set_value(cdt, cdn, "actual_qty", r.message[0].actual_qty);
}
},
});
}
},
});

View File

@@ -974,8 +974,14 @@ class ProductionPlan(Document):
bom_data = []
warehouse = (self.sub_assembly_warehouse) if self.skip_available_sub_assembly_item else None
get_sub_assembly_items(row.bom_no, bom_data, row.planned_qty, self.company, warehouse=warehouse)
get_sub_assembly_items(
row.bom_no,
bom_data,
row.planned_qty,
self.company,
warehouse=self.sub_assembly_warehouse,
skip_available_sub_assembly_item=self.skip_available_sub_assembly_item,
)
self.set_sub_assembly_items_based_on_level(row, bom_data, manufacturing_type)
sub_assembly_items_store.extend(bom_data)
@@ -1766,14 +1772,23 @@ def get_item_data(item_code):
}
def get_sub_assembly_items(bom_no, bom_data, to_produce_qty, company, warehouse=None, indent=0):
def get_sub_assembly_items(
bom_no,
bom_data,
to_produce_qty,
company,
warehouse=None,
indent=0,
skip_available_sub_assembly_item=False,
):
data = get_bom_children(parent=bom_no)
for d in data:
if d.expandable:
parent_item_code = frappe.get_cached_value("BOM", bom_no, "item")
stock_qty = (d.stock_qty / d.parent_bom_qty) * flt(to_produce_qty)
if warehouse:
bin_details = frappe._dict()
if skip_available_sub_assembly_item:
bin_details = get_bin_details(d, company, for_warehouse=warehouse)
for _bin_dict in bin_details:
@@ -1783,11 +1798,14 @@ def get_sub_assembly_items(bom_no, bom_data, to_produce_qty, company, warehouse=
continue
else:
stock_qty = stock_qty - _bin_dict.projected_qty
elif warehouse:
bin_details = get_bin_details(d, company, for_warehouse=warehouse)
if stock_qty > 0:
bom_data.append(
frappe._dict(
{
"actual_qty": bin_details[0].get("actual_qty", 0) if bin_details else 0,
"parent_item_code": parent_item_code,
"description": d.description,
"production_item": d.item_code,
@@ -1805,7 +1823,13 @@ def get_sub_assembly_items(bom_no, bom_data, to_produce_qty, company, warehouse=
if d.value:
get_sub_assembly_items(
d.value, bom_data, stock_qty, company, warehouse, indent=indent + 1
d.value,
bom_data,
stock_qty,
company,
warehouse,
indent=indent + 1,
skip_available_sub_assembly_item=skip_available_sub_assembly_item,
)