From 7dcf0f0866c62f9b798383b6d74df046179a591b Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 12 Jan 2023 20:32:37 +0530 Subject: [PATCH] fix: only group similar items in print format if group_same_items is checked in pick list (backport #33627) (#33631) fix: only group similar items in print format if group_same_items is checked in pick list (#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 (cherry picked from commit cfb0bb1eaa31c23ae8ce4c87c5a11c3e46d83789) Co-authored-by: Ritwik Puri --- erpnext/stock/doctype/pick_list/pick_list.py | 3 ++- erpnext/stock/doctype/pick_list/test_pick_list.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/pick_list/pick_list.py b/erpnext/stock/doctype/pick_list/pick_list.py index 4c02d94fe83..effba8e579b 100644 --- a/erpnext/stock/doctype/pick_list/pick_list.py +++ b/erpnext/stock/doctype/pick_list/pick_list.py @@ -198,7 +198,8 @@ class PickList(Document): 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) diff --git a/erpnext/stock/doctype/pick_list/test_pick_list.py b/erpnext/stock/doctype/pick_list/test_pick_list.py index e8cebc8e622..681e47b3df0 100644 --- a/erpnext/stock/doctype/pick_list/test_pick_list.py +++ b/erpnext/stock/doctype/pick_list/test_pick_list.py @@ -432,6 +432,20 @@ class TestPickList(FrappeTestCase): 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",