Added validation to prevent transfer of raw material from an expired batch for manufacturing
This commit is contained in:
		
							parent
							
								
									01c7ce1da3
								
							
						
					
					
						commit
						035160c9a6
					
				| @ -5,7 +5,7 @@ from __future__ import unicode_literals | ||||
| import frappe | ||||
| import frappe.defaults | ||||
| 
 | ||||
| from frappe.utils import cstr, cint, flt, comma_or, get_datetime | ||||
| from frappe.utils import cstr, cint, flt, comma_or, get_datetime, getdate | ||||
| 
 | ||||
| from frappe import _ | ||||
| from erpnext.stock.utils import get_incoming_rate | ||||
| @ -66,6 +66,7 @@ class StockEntry(StockController): | ||||
| 		self.validate_valuation_rate() | ||||
| 		self.set_total_incoming_outgoing_value() | ||||
| 		self.set_total_amount() | ||||
| 		self.validate_batch() | ||||
| 
 | ||||
| 	def on_submit(self): | ||||
| 		self.update_stock_ledger() | ||||
| @ -724,6 +725,13 @@ class StockEntry(StockController): | ||||
| 				mreq_item.warehouse != (item.s_warehouse if self.purpose== "Material Issue" else item.t_warehouse): | ||||
| 					frappe.throw(_("Item or Warehouse for row {0} does not match Material Request").format(item.idx), | ||||
| 						frappe.MappingMismatchError) | ||||
| 						 | ||||
| 	def validate_batch(self): | ||||
| 		if self.purpose == "Material Transfer for Manufacture": | ||||
| 			for item in self.get("items"): | ||||
| 				if item.batch_no: | ||||
| 					if getdate(self.posting_date) > getdate(frappe.db.get_value("Batch", item.batch_no, "expiry_date")): | ||||
| 						frappe.throw(_("Batch {0} of Item {1} has expired.").format(item.batch_no, item.item_code)) | ||||
| 
 | ||||
| @frappe.whitelist() | ||||
| def get_party_details(ref_dt, ref_dn): | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user