fix: tests

(cherry picked from commit d26f8aa629)
This commit is contained in:
Mihir Kandoi
2025-11-21 10:51:19 +05:30
committed by Mergify
parent 2809c46a6e
commit 45bc218acb

View File

@@ -7,7 +7,7 @@ from itertools import groupby
import frappe import frappe
from frappe import _, bold from frappe import _, bold
from frappe.model.mapper import get_mapped_doc, map_child_doc from frappe.model.mapper import map_child_doc
from frappe.query_builder import Case from frappe.query_builder import Case
from frappe.query_builder.custom import GROUP_CONCAT from frappe.query_builder.custom import GROUP_CONCAT
from frappe.query_builder.functions import Coalesce, Locate, Replace, Sum from frappe.query_builder.functions import Coalesce, Locate, Replace, Sum
@@ -644,9 +644,7 @@ class PickList(TransactionBase):
def update_bundle_picked_qty(self): def update_bundle_picked_qty(self):
product_bundles = self._get_product_bundles() product_bundles = self._get_product_bundles()
product_bundle_qty_map = self._get_product_bundle_qty_map( product_bundle_qty_map = self._get_product_bundle_qty_map(product_bundles.values())
next(iter(product_bundles.values())).get("item_code")
)
for so_row, value in product_bundles.items(): for so_row, value in product_bundles.items():
picked_qty = self._compute_picked_qty_for_bundle(so_row, product_bundle_qty_map[value.item_code]) picked_qty = self._compute_picked_qty_for_bundle(so_row, product_bundle_qty_map[value.item_code])
@@ -784,15 +782,11 @@ class PickList(TransactionBase):
) )
return product_bundles return product_bundles
def _get_product_bundle_qty_map(self, bundles: list[str]) -> dict[str, dict[str, float]]: def _get_product_bundle_qty_map(self, bundles) -> dict[str, dict[str, float]]:
# bundle_item_code: Dict[component, qty]
if isinstance(bundles, str):
bundles = [bundles]
product_bundle_qty_map = {} product_bundle_qty_map = {}
for bundle_item_code in bundles: for data in bundles:
bundle = frappe.get_last_doc("Product Bundle", {"new_item_code": bundle_item_code, "disabled": 0}) bundle = frappe.get_last_doc("Product Bundle", {"new_item_code": data.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[data.item_code] = {item.item_code: item.qty for item in bundle.items}
return product_bundle_qty_map return product_bundle_qty_map
def _compute_picked_qty_for_bundle(self, bundle_row, bundle_items) -> int: def _compute_picked_qty_for_bundle(self, bundle_row, bundle_items) -> int:
@@ -1396,9 +1390,7 @@ def add_product_bundles_to_delivery_note(
When mapping pick list items, the bundle item itself isn't part of the When mapping pick list items, the bundle item itself isn't part of the
locations. Dynamically fetch and add parent bundle item into DN.""" locations. Dynamically fetch and add parent bundle item into DN."""
product_bundles = pick_list._get_product_bundles() product_bundles = pick_list._get_product_bundles()
product_bundle_qty_map = pick_list._get_product_bundle_qty_map( product_bundle_qty_map = pick_list._get_product_bundle_qty_map(product_bundles.values())
next(iter(product_bundles.values())).get("item_code")
)
for so_row, value in product_bundles.items(): for so_row, value in product_bundles.items():
sales_order_item = frappe.get_doc("Sales Order Item", so_row) sales_order_item = frappe.get_doc("Sales Order Item", so_row)