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>
This commit is contained in:
Ritwik Puri 2023-01-12 17:25:50 +05:30 committed by GitHub
parent e0db2670f9
commit cfb0bb1eaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -230,7 +230,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

@ -445,6 +445,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",