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 <sagarsharma.s312@gmail.com>
(cherry picked from commit cfb0bb1eaa)

Co-authored-by: Ritwik Puri <ritwikpuri5678@gmail.com>
This commit is contained in:
mergify[bot]
2023-01-12 20:32:37 +05:30
committed by GitHub
parent 29dcce53db
commit 7dcf0f0866
2 changed files with 16 additions and 1 deletions

View File

@@ -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)

View File

@@ -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",