mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-15 12:55:10 +00:00
fix: actual qty showing blank for sub-assembly items
(cherry picked from commit 5be2e71a35)
This commit is contained in:
committed by
Mergify
parent
7fc70e3f20
commit
d0748b1b67
@@ -562,6 +562,28 @@ frappe.ui.form.on("Production Plan Sales Order", {
|
|||||||
frappe.ui.form.on("Production Plan Sub Assembly Item", {
|
frappe.ui.form.on("Production Plan Sub Assembly Item", {
|
||||||
fg_warehouse(frm, cdt, cdn) {
|
fg_warehouse(frm, cdt, cdn) {
|
||||||
erpnext.utils.copy_value_in_all_rows(frm.doc, cdt, cdn, "sub_assembly_items", "fg_warehouse");
|
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);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -937,8 +937,14 @@ class ProductionPlan(Document):
|
|||||||
|
|
||||||
bom_data = []
|
bom_data = []
|
||||||
|
|
||||||
warehouse = (self.sub_assembly_warehouse) if self.skip_available_sub_assembly_item else None
|
get_sub_assembly_items(
|
||||||
get_sub_assembly_items(row.bom_no, bom_data, row.planned_qty, self.company, warehouse=warehouse)
|
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)
|
self.set_sub_assembly_items_based_on_level(row, bom_data, manufacturing_type)
|
||||||
sub_assembly_items_store.extend(bom_data)
|
sub_assembly_items_store.extend(bom_data)
|
||||||
|
|
||||||
@@ -1729,14 +1735,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)
|
data = get_bom_children(parent=bom_no)
|
||||||
for d in data:
|
for d in data:
|
||||||
if d.expandable:
|
if d.expandable:
|
||||||
parent_item_code = frappe.get_cached_value("BOM", bom_no, "item")
|
parent_item_code = frappe.get_cached_value("BOM", bom_no, "item")
|
||||||
stock_qty = (d.stock_qty / d.parent_bom_qty) * flt(to_produce_qty)
|
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)
|
bin_details = get_bin_details(d, company, for_warehouse=warehouse)
|
||||||
|
|
||||||
for _bin_dict in bin_details:
|
for _bin_dict in bin_details:
|
||||||
@@ -1746,11 +1761,14 @@ def get_sub_assembly_items(bom_no, bom_data, to_produce_qty, company, warehouse=
|
|||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
stock_qty = stock_qty - _bin_dict.projected_qty
|
stock_qty = stock_qty - _bin_dict.projected_qty
|
||||||
|
elif warehouse:
|
||||||
|
bin_details = get_bin_details(d, company, for_warehouse=warehouse)
|
||||||
|
|
||||||
if stock_qty > 0:
|
if stock_qty > 0:
|
||||||
bom_data.append(
|
bom_data.append(
|
||||||
frappe._dict(
|
frappe._dict(
|
||||||
{
|
{
|
||||||
|
"actual_qty": bin_details[0].get("actual_qty", 0) if bin_details else 0,
|
||||||
"parent_item_code": parent_item_code,
|
"parent_item_code": parent_item_code,
|
||||||
"description": d.description,
|
"description": d.description,
|
||||||
"production_item": d.item_code,
|
"production_item": d.item_code,
|
||||||
@@ -1768,7 +1786,13 @@ def get_sub_assembly_items(bom_no, bom_data, to_produce_qty, company, warehouse=
|
|||||||
|
|
||||||
if d.value:
|
if d.value:
|
||||||
get_sub_assembly_items(
|
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,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user