feat(pick list): group items based on item code and warehouse before printing picklist
This commit is contained in:
parent
6ec047cba9
commit
f2d136e574
@ -18,7 +18,9 @@
|
|||||||
"get_item_locations",
|
"get_item_locations",
|
||||||
"section_break_6",
|
"section_break_6",
|
||||||
"locations",
|
"locations",
|
||||||
"amended_from"
|
"amended_from",
|
||||||
|
"print_settings_section",
|
||||||
|
"group_same_items"
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
@ -110,14 +112,28 @@
|
|||||||
"options": "STO-PICK-.YYYY.-",
|
"options": "STO-PICK-.YYYY.-",
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"set_only_once": 1
|
"set_only_once": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "print_settings_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Print Settings"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 1,
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "group_same_items",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Group Same Items",
|
||||||
|
"print_hide": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2020-03-17 11:38:41.932875",
|
"modified": "2021-10-05 15:08:40.369957",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Pick List",
|
"name": "Pick List",
|
||||||
|
"naming_rule": "By \"Naming Series\" field",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
{
|
{
|
||||||
@ -184,4 +200,4 @@
|
|||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"track_changes": 1
|
"track_changes": 1
|
||||||
}
|
}
|
@ -121,6 +121,32 @@ class PickList(Document):
|
|||||||
and (self.for_qty is None or self.for_qty == 0):
|
and (self.for_qty is None or self.for_qty == 0):
|
||||||
frappe.throw(_("Qty of Finished Goods Item should be greater than 0."))
|
frappe.throw(_("Qty of Finished Goods Item should be greater than 0."))
|
||||||
|
|
||||||
|
def before_print(self, settings=None):
|
||||||
|
if self.get("group_same_items"):
|
||||||
|
self.group_similar_items()
|
||||||
|
|
||||||
|
def group_similar_items(self):
|
||||||
|
group_item_qty = {}
|
||||||
|
group_picked_qty = {}
|
||||||
|
count = 0
|
||||||
|
|
||||||
|
for item in self.locations:
|
||||||
|
group_item_qty[(item.item_code, item.warehouse)] = group_item_qty.get((item.item_code,item.warehouse), 0) + item.qty
|
||||||
|
group_picked_qty[(item.item_code, item.warehouse)] = group_picked_qty.get((item.item_code,item.warehouse), 0) + item.picked_qty
|
||||||
|
|
||||||
|
duplicate_list = []
|
||||||
|
for item in self.locations:
|
||||||
|
if (item.item_code, item.warehouse) in group_item_qty:
|
||||||
|
count += 1
|
||||||
|
item.qty = group_item_qty[(item.item_code, item.warehouse)]
|
||||||
|
item.picked_qty = group_picked_qty[(item.item_code, item.warehouse)]
|
||||||
|
item.stock_qty = group_item_qty[(item.item_code, item.warehouse)]
|
||||||
|
item.idx = count
|
||||||
|
del group_item_qty[(item.item_code, item.warehouse)]
|
||||||
|
else:
|
||||||
|
duplicate_list.append(item)
|
||||||
|
for item in duplicate_list:
|
||||||
|
self.remove(item)
|
||||||
|
|
||||||
def validate_item_locations(pick_list):
|
def validate_item_locations(pick_list):
|
||||||
if not pick_list.locations:
|
if not pick_list.locations:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user