Skip to content

Commit

Permalink
fix: skip disabled bundles for non-report utils
Browse files Browse the repository at this point in the history
(cherry picked from commit 362f377)
  • Loading branch information
GursheenK authored and mergify[bot] committed Nov 24, 2023
1 parent e4d9ef1 commit 3d46b32
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions erpnext/stock/doctype/delivery_note/delivery_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ def get_product_bundle_list(self):
items_list = [item.item_code for item in self.items]
return frappe.db.get_all(
"Product Bundle",
filters={"new_item_code": ["in", items_list]},
filters={"new_item_code": ["in", items_list], "disabled": 0},
pluck="name",
)

Expand Down Expand Up @@ -938,7 +938,7 @@ def update_item(obj, target, source_parent):
},
"postprocess": update_item,
"condition": lambda item: (
not frappe.db.exists("Product Bundle", {"new_item_code": item.item_code})
not frappe.db.exists("Product Bundle", {"new_item_code": item.item_code, "disabled": 0})
and flt(item.packed_qty) < flt(item.qty)
),
},
Expand Down
8 changes: 6 additions & 2 deletions erpnext/stock/doctype/item/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,12 @@ def validate_properties_before_merge(self, new_name):

def validate_duplicate_product_bundles_before_merge(self, old_name, new_name):
"Block merge if both old and new items have product bundles."
old_bundle = frappe.get_value("Product Bundle", filters={"new_item_code": old_name})
new_bundle = frappe.get_value("Product Bundle", filters={"new_item_code": new_name})
old_bundle = frappe.get_value(
"Product Bundle", filters={"new_item_code": old_name, "disabled": 0}
)
new_bundle = frappe.get_value(
"Product Bundle", filters={"new_item_code": new_name, "disabled": 0}
)

if old_bundle and new_bundle:
bundle_link = get_link_to_form("Product Bundle", old_bundle)
Expand Down
2 changes: 1 addition & 1 deletion erpnext/stock/doctype/packed_item/packed_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def make_packing_list(doc):


def is_product_bundle(item_code: str) -> bool:
return bool(frappe.db.exists("Product Bundle", {"new_item_code": item_code}))
return bool(frappe.db.exists("Product Bundle", {"new_item_code": item_code, "disabled": 0}))


def get_indexed_packed_items_table(doc):
Expand Down
8 changes: 6 additions & 2 deletions erpnext/stock/doctype/pick_list/pick_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,9 @@ def aggregate_item_qty(self):
frappe.throw("Row #{0}: Item Code is Mandatory".format(item.idx))
if not cint(
frappe.get_cached_value("Item", item.item_code, "is_stock_item")
) and not frappe.db.exists("Product Bundle", {"new_item_code": item.item_code}):
) and not frappe.db.exists(
"Product Bundle", {"new_item_code": item.item_code, "disabled": 0}
):
continue
item_code = item.item_code
reference = item.sales_order_item or item.material_request_item
Expand Down Expand Up @@ -507,7 +509,9 @@ def _get_product_bundle_qty_map(self, bundles: List[str]) -> Dict[str, Dict[str,
# bundle_item_code: Dict[component, qty]
product_bundle_qty_map = {}
for bundle_item_code in bundles:
bundle = frappe.get_last_doc("Product Bundle", {"new_item_code": bundle_item_code})
bundle = frappe.get_last_doc(
"Product Bundle", {"new_item_code": bundle_item_code, "disabled": 0}
)
product_bundle_qty_map[bundle_item_code] = {item.item_code: item.qty for item in bundle.items}
return product_bundle_qty_map

Expand Down

0 comments on commit 3d46b32

Please sign in to comment.