Skip to content

Commit

Permalink
fix: only group similar items in print format if group_same_items is …
Browse files Browse the repository at this point in the history
…checked in pick list (frappe#33627)

* fix: only group similar items if group same items is checked in pick list

* test: non grouping of locations if group_same_items is false

Co-authored-by: Sagar Sharma <sagarsharma.s312@gmail.com>
  • Loading branch information
phot0n and s-aga-r authored Jan 12, 2023
1 parent e0db267 commit cfb0bb1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion erpnext/stock/doctype/pick_list/pick_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ def validate_for_qty(self):
frappe.throw(_("Qty of Finished Goods Item should be greater than 0."))

def before_print(self, settings=None):
self.group_similar_items()
if self.group_same_items:
self.group_similar_items()

def group_similar_items(self):
group_item_qty = defaultdict(float)
Expand Down
14 changes: 14 additions & 0 deletions erpnext/stock/doctype/pick_list/test_pick_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,20 @@ def _compare_dicts(a, b):
pl.before_print()
self.assertEqual(len(pl.locations), 4)

# grouping should not happen if group_same_items is False
pl = frappe.get_doc(
doctype="Pick List",
group_same_items=False,
locations=[
_dict(item_code="A", warehouse="X", qty=5, picked_qty=1),
_dict(item_code="B", warehouse="Y", qty=4, picked_qty=2),
_dict(item_code="A", warehouse="X", qty=3, picked_qty=2),
_dict(item_code="B", warehouse="Y", qty=2, picked_qty=2),
],
)
pl.before_print()
self.assertEqual(len(pl.locations), 4)

# grouping should halve the number of items
pl = frappe.get_doc(
doctype="Pick List",
Expand Down

0 comments on commit cfb0bb1

Please sign in to comment.