Skip to content

Commit

Permalink
refactor: misc pick list refactors
Browse files Browse the repository at this point in the history
- make tracking fields read only and no-copy 🤦
- collapse print settings section, most users configure it once and
  forget about it, not need to show this.
- call pick list grouping function directly
- use get_descendants_of instead of obscure db function
  • Loading branch information
ankush committed Apr 27, 2022
1 parent 24a7aca commit 5c3f901
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion erpnext/selling/doctype/sales_order/sales_order.json
Original file line number Diff line number Diff line change
Expand Up @@ -1520,14 +1520,15 @@
"fieldname": "per_picked",
"fieldtype": "Percent",
"label": "% Picked",
"no_copy": 1,
"read_only": 1
}
],
"icon": "fa fa-file-text",
"idx": 105,
"is_submittable": 1,
"links": [],
"modified": "2022-03-15 21:38:31.437586",
"modified": "2022-04-21 08:16:48.316074",
"modified_by": "Administrator",
"module": "Selling",
"name": "Sales Order",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -803,13 +803,15 @@
{
"fieldname": "picked_qty",
"fieldtype": "Float",
"label": "Picked Qty"
"label": "Picked Qty",
"no_copy": 1,
"read_only": 1
}
],
"idx": 1,
"istable": 1,
"links": [],
"modified": "2022-03-15 20:17:33.984799",
"modified": "2022-04-21 08:15:14.010319",
"modified_by": "Administrator",
"module": "Selling",
"name": "Sales Order Item",
Expand Down
4 changes: 3 additions & 1 deletion erpnext/stock/doctype/pick_list/pick_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
"set_only_once": 1
},
{
"collapsible": 1,
"fieldname": "print_settings_section",
"fieldtype": "Section Break",
"label": "Print Settings"
Expand All @@ -129,7 +130,7 @@
],
"is_submittable": 1,
"links": [],
"modified": "2021-10-05 15:08:40.369957",
"modified": "2022-04-21 07:56:40.646473",
"modified_by": "Administrator",
"module": "Stock",
"name": "Pick List",
Expand Down Expand Up @@ -199,5 +200,6 @@
],
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"track_changes": 1
}
6 changes: 3 additions & 3 deletions erpnext/stock/doctype/pick_list/pick_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from frappe.model.document import Document
from frappe.model.mapper import map_child_doc
from frappe.utils import cint, floor, flt, today
from frappe.utils.nestedset import get_descendants_of

from erpnext.selling.doctype.sales_order.sales_order import (
make_delivery_note as create_delivery_note_from_sales_order,
Expand Down Expand Up @@ -109,7 +110,7 @@ def set_item_locations(self, save=False):

from_warehouses = None
if self.parent_warehouse:
from_warehouses = frappe.db.get_descendants("Warehouse", self.parent_warehouse)
from_warehouses = get_descendants_of("Warehouse", self.parent_warehouse)

# Create replica before resetting, to handle empty table on update after submit.
locations_replica = self.get("locations")
Expand Down Expand Up @@ -190,8 +191,7 @@ def validate_for_qty(self):
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()
self.group_similar_items()

def group_similar_items(self):
group_item_qty = defaultdict(float)
Expand Down

0 comments on commit 5c3f901

Please sign in to comment.