chore: add status field in Pick List
				
					
				
			This commit is contained in:
		
							parent
							
								
									b642718f08
								
							
						
					
					
						commit
						be41052dc8
					
				| @ -325,3 +325,4 @@ erpnext.patches.v14_0.setup_clear_repost_logs | ||||
| erpnext.patches.v14_0.create_accounting_dimensions_for_payment_request | ||||
| erpnext.patches.v14_0.update_entry_type_for_journal_entry | ||||
| erpnext.patches.v14_0.change_autoname_for_tax_withheld_vouchers | ||||
| erpnext.patches.v14_0.set_pick_list_status | ||||
|  | ||||
							
								
								
									
										40
									
								
								erpnext/patches/v14_0/set_pick_list_status.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								erpnext/patches/v14_0/set_pick_list_status.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,40 @@ | ||||
| # Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and Contributors | ||||
| # License: MIT. See LICENSE | ||||
| 
 | ||||
| 
 | ||||
| import frappe | ||||
| from pypika.terms import ExistsCriterion | ||||
| 
 | ||||
| 
 | ||||
| def execute(): | ||||
| 	pl = frappe.qb.DocType("Pick List") | ||||
| 	se = frappe.qb.DocType("Stock Entry") | ||||
| 	dn = frappe.qb.DocType("Delivery Note") | ||||
| 
 | ||||
| 	( | ||||
| 		frappe.qb.update(pl).set( | ||||
| 			pl.status, | ||||
| 			( | ||||
| 				frappe.qb.terms.Case() | ||||
| 				.when(pl.docstatus == 0, "Draft") | ||||
| 				.when(pl.docstatus == 2, "Cancelled") | ||||
| 				.else_("Completed") | ||||
| 			), | ||||
| 		) | ||||
| 	).run() | ||||
| 
 | ||||
| 	( | ||||
| 		frappe.qb.update(pl) | ||||
| 		.set(pl.status, "Open") | ||||
| 		.where( | ||||
| 			( | ||||
| 				ExistsCriterion( | ||||
| 					frappe.qb.from_(se).select(se.name).where((se.docstatus == 1) & (se.pick_list == pl.name)) | ||||
| 				) | ||||
| 				| ExistsCriterion( | ||||
| 					frappe.qb.from_(dn).select(dn.name).where((dn.docstatus == 1) & (dn.pick_list == pl.name)) | ||||
| 				) | ||||
| 			).negate() | ||||
| 			& (pl.docstatus == 1) | ||||
| 		) | ||||
| 	).run() | ||||
| @ -228,6 +228,7 @@ class DeliveryNote(SellingController): | ||||
| 
 | ||||
| 	def on_submit(self): | ||||
| 		self.validate_packed_qty() | ||||
| 		self.update_pick_list_status() | ||||
| 
 | ||||
| 		# Check for Approving Authority | ||||
| 		frappe.get_doc("Authorization Control").validate_approving_authority( | ||||
| @ -313,6 +314,11 @@ class DeliveryNote(SellingController): | ||||
| 		if has_error: | ||||
| 			raise frappe.ValidationError | ||||
| 
 | ||||
| 	def update_pick_list_status(self): | ||||
| 		from erpnext.stock.doctype.pick_list.pick_list import update_pick_list_status | ||||
| 
 | ||||
| 		update_pick_list_status(self.pick_list) | ||||
| 
 | ||||
| 	def check_next_docstatus(self): | ||||
| 		submit_rv = frappe.db.sql( | ||||
| 			"""select t1.name | ||||
|  | ||||
| @ -26,7 +26,8 @@ | ||||
|   "locations", | ||||
|   "amended_from", | ||||
|   "print_settings_section", | ||||
|   "group_same_items" | ||||
|   "group_same_items", | ||||
|   "status" | ||||
|  ], | ||||
|  "fields": [ | ||||
|   { | ||||
| @ -168,11 +169,26 @@ | ||||
|    "fieldtype": "Data", | ||||
|    "label": "Customer Name", | ||||
|    "read_only": 1 | ||||
|   }, | ||||
|   { | ||||
|    "default": "Draft", | ||||
|    "fieldname": "status", | ||||
|    "fieldtype": "Select", | ||||
|    "hidden": 1, | ||||
|    "in_standard_filter": 1, | ||||
|    "label": "Status", | ||||
|    "no_copy": 1, | ||||
|    "options": "Draft\nOpen\nCompleted\nCancelled", | ||||
|    "print_hide": 1, | ||||
|    "read_only": 1, | ||||
|    "report_hide": 1, | ||||
|    "reqd": 1, | ||||
|    "search_index": 1 | ||||
|   } | ||||
|  ], | ||||
|  "is_submittable": 1, | ||||
|  "links": [], | ||||
|  "modified": "2022-07-19 11:03:04.442174", | ||||
|  "modified": "2023-01-24 10:33:43.244476", | ||||
|  "modified_by": "Administrator", | ||||
|  "module": "Stock", | ||||
|  "name": "Pick List", | ||||
| @ -244,4 +260,4 @@ | ||||
|  "sort_order": "DESC", | ||||
|  "states": [], | ||||
|  "track_changes": 1 | ||||
| } | ||||
| } | ||||
| @ -77,15 +77,32 @@ class PickList(Document): | ||||
| 				) | ||||
| 
 | ||||
| 	def on_submit(self): | ||||
| 		self.update_status() | ||||
| 		self.update_bundle_picked_qty() | ||||
| 		self.update_reference_qty() | ||||
| 		self.update_sales_order_picking_status() | ||||
| 
 | ||||
| 	def on_cancel(self): | ||||
| 		self.update_status() | ||||
| 		self.update_bundle_picked_qty() | ||||
| 		self.update_reference_qty() | ||||
| 		self.update_sales_order_picking_status() | ||||
| 
 | ||||
| 	def update_status(self, status=None, update_modified=True): | ||||
| 		if not status: | ||||
| 			if self.docstatus == 0: | ||||
| 				status = "Draft" | ||||
| 			elif self.docstatus == 1: | ||||
| 				if self.status == "Draft": | ||||
| 					status = "Open" | ||||
| 				elif target_document_exists(self.name, self.purpose): | ||||
| 					status = "Completed" | ||||
| 			elif self.docstatus == 2: | ||||
| 				status = "Cancelled" | ||||
| 
 | ||||
| 		if status: | ||||
| 			frappe.db.set_value("Pick List", self.name, "status", status, update_modified=update_modified) | ||||
| 
 | ||||
| 	def update_reference_qty(self): | ||||
| 		packed_items = [] | ||||
| 		so_items = [] | ||||
| @ -394,6 +411,12 @@ class PickList(Document): | ||||
| 		return int(flt(min(possible_bundles), precision or 6)) | ||||
| 
 | ||||
| 
 | ||||
| def update_pick_list_status(pick_list): | ||||
| 	if pick_list: | ||||
| 		doc = frappe.get_doc("Pick List", pick_list) | ||||
| 		doc.run_method("update_status") | ||||
| 
 | ||||
| 
 | ||||
| def get_picked_items_qty(items) -> List[Dict]: | ||||
| 	pi_item = frappe.qb.DocType("Pick List Item") | ||||
| 	return ( | ||||
|  | ||||
							
								
								
									
										14
									
								
								erpnext/stock/doctype/pick_list/pick_list_list.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								erpnext/stock/doctype/pick_list/pick_list_list.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,14 @@ | ||||
| // Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors
 | ||||
| // For license information, please see license.txt
 | ||||
| 
 | ||||
| frappe.listview_settings['Pick List'] = { | ||||
| 	get_indicator: function (doc) { | ||||
| 		const status_colors = { | ||||
| 			"Draft": "grey", | ||||
| 			"Open": "orange", | ||||
| 			"Completed": "green", | ||||
| 			"Cancelled": "red", | ||||
| 		}; | ||||
| 		return [__(doc.status), status_colors[doc.status], "status,=," + doc.status]; | ||||
| 	}, | ||||
| }; | ||||
| @ -158,6 +158,7 @@ class StockEntry(StockController): | ||||
| 		self.validate_subcontract_order() | ||||
| 		self.update_subcontract_order_supplied_items() | ||||
| 		self.update_subcontracting_order_status() | ||||
| 		self.update_pick_list_status() | ||||
| 
 | ||||
| 		self.make_gl_entries() | ||||
| 
 | ||||
| @ -2276,6 +2277,11 @@ class StockEntry(StockController): | ||||
| 
 | ||||
| 			update_subcontracting_order_status(self.subcontracting_order) | ||||
| 
 | ||||
| 	def update_pick_list_status(self): | ||||
| 		from erpnext.stock.doctype.pick_list.pick_list import update_pick_list_status | ||||
| 
 | ||||
| 		update_pick_list_status(self.pick_list) | ||||
| 
 | ||||
| 	def set_missing_values(self): | ||||
| 		"Updates rate and availability of all the items of mapped doc." | ||||
| 		self.set_transfer_qty() | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user