fix: skip disabled bundles for non-report utils

(cherry picked from commit 362f377f6127e9262ab7829a427d0a2051a77b2f)
This commit is contained in:
Gursheen Anand 2023-11-22 16:26:09 +05:30 committed by Mergify
parent e4d9ef1293
commit 3d46b323b3
4 changed files with 15 additions and 7 deletions

View File

@ -615,7 +615,7 @@ class DeliveryNote(SellingController):
items_list = [item.item_code for item in self.items] items_list = [item.item_code for item in self.items]
return frappe.db.get_all( return frappe.db.get_all(
"Product Bundle", "Product Bundle",
filters={"new_item_code": ["in", items_list]}, filters={"new_item_code": ["in", items_list], "disabled": 0},
pluck="name", pluck="name",
) )
@ -938,7 +938,7 @@ def make_packing_slip(source_name, target_doc=None):
}, },
"postprocess": update_item, "postprocess": update_item,
"condition": lambda 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) and flt(item.packed_qty) < flt(item.qty)
), ),
}, },

View File

@ -512,8 +512,12 @@ class Item(Document):
def validate_duplicate_product_bundles_before_merge(self, old_name, 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." "Block merge if both old and new items have product bundles."
old_bundle = frappe.get_value("Product Bundle", filters={"new_item_code": old_name}) old_bundle = frappe.get_value(
new_bundle = frappe.get_value("Product Bundle", filters={"new_item_code": new_name}) "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: if old_bundle and new_bundle:
bundle_link = get_link_to_form("Product Bundle", old_bundle) bundle_link = get_link_to_form("Product Bundle", old_bundle)

View File

@ -55,7 +55,7 @@ def make_packing_list(doc):
def is_product_bundle(item_code: str) -> bool: 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): def get_indexed_packed_items_table(doc):

View File

@ -368,7 +368,9 @@ class PickList(Document):
frappe.throw("Row #{0}: Item Code is Mandatory".format(item.idx)) frappe.throw("Row #{0}: Item Code is Mandatory".format(item.idx))
if not cint( if not cint(
frappe.get_cached_value("Item", item.item_code, "is_stock_item") 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 continue
item_code = item.item_code item_code = item.item_code
reference = item.sales_order_item or item.material_request_item reference = item.sales_order_item or item.material_request_item
@ -507,7 +509,9 @@ class PickList(Document):
# bundle_item_code: Dict[component, qty] # bundle_item_code: Dict[component, qty]
product_bundle_qty_map = {} product_bundle_qty_map = {}
for bundle_item_code in bundles: 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} product_bundle_qty_map[bundle_item_code] = {item.item_code: item.qty for item in bundle.items}
return product_bundle_qty_map return product_bundle_qty_map