fix: add more validations, remove source wh req for pl item
This commit is contained in:
		
							parent
							
								
									8ecb146231
								
							
						
					
					
						commit
						cdf253aeb4
					
				| @ -695,25 +695,28 @@ class BOM(WebsiteGenerator): | ||||
| 	def validate_scrap_items(self): | ||||
| 		for item in self.scrap_items: | ||||
| 			if item.item_code == self.item and not item.is_process_loss: | ||||
| 				frappe.throw(_('Scrap/Loss Item:') + f' {frappe.bold(item.item_code)} ' +\ | ||||
| 					_('should have') + ' ' + frappe.bold(_('Is Process Loss')) + ' ' + ('checked.')) | ||||
| 				frappe.throw(_('Scrap/Loss Item:') + f' {frappe.bold(item.item_code)} ' + | ||||
| 					_('should have') + ' ' + frappe.bold(_('Is Process Loss')) + ' ' + ('checked')) | ||||
| 			elif item.item_code != self.item and item.is_process_loss: | ||||
| 				frappe.throw(_('Scrap/Loss Item:') + f' {frappe.bold(item.item_code)} ' +\ | ||||
| 					_('should not have') + ' ' + frappe.bold(_('Is Process Loss')) + ' ' + ('checked.')) | ||||
| 				frappe.throw(_('Scrap/Loss Item:') + f' {frappe.bold(item.item_code)} ' + | ||||
| 					_('should not have') + ' ' + frappe.bold(_('Is Process Loss')) + ' ' + ('checked')) | ||||
| 
 | ||||
| 			stock_uom = item.stock_uom | ||||
| 			must_be_whole_number = frappe.get_value("UOM", stock_uom, "must_be_whole_number") | ||||
| 			must_be_whole_number = frappe.get_value("UOM", item.stock_uom, "must_be_whole_number") | ||||
| 			if item.is_process_loss and must_be_whole_number: | ||||
| 				frappe.throw(_('Item:') + f' {frappe.bold(item.item_code)} ' +\ | ||||
| 					_('with Stock UOM:') + f' {frappe.bold(stock_uom)} '+\ | ||||
| 					_('cannot be a Scrap/Loss Item.')) | ||||
| 				frappe.throw(_('Item:') + f' {frappe.bold(item.item_code)} ' + | ||||
| 					_('with Stock UOM:') + f' {frappe.bold(item.stock_uom)} ' + | ||||
| 					_('cannot be a Scrap/Loss Item')) | ||||
| 
 | ||||
| 			if item.is_process_loss and (item.stock_qty >= self.quantity): | ||||
| 				frappe.throw(_('Scrap/Loss Item:') + f' {item.item_code} ' +\ | ||||
| 					_('should have') +' '+frappe.bold(_('Qty')) +\ | ||||
| 					' ' + _('less than finished goods') + ' ' +\ | ||||
| 					frappe.bold(_('Quantity.'))) | ||||
| 				frappe.throw(_('Scrap/Loss Item:') + f' {item.item_code} ' + | ||||
| 					_('should have') +' '+frappe.bold(_('Qty')) + ' ' + | ||||
| 					_('less than finished goods') + ' ' + frappe.bold(_('Quantity'))) | ||||
| 
 | ||||
| 			if item.is_process_loss and (item.rate > 0): | ||||
| 				frappe.throw(_('Scrap/Loss Item:') + f' {item.item_code} ' + | ||||
| 					_('should have') + ' ' + frappe.bold(_('Rate')) + | ||||
| 					' ' + _('set to 0 because') + ' ' + | ||||
| 					frappe.bold(_('Is Process Loss')) + ' ' + _('is checked')) | ||||
| 
 | ||||
| def get_bom_item_rate(args, bom_doc): | ||||
| 	if bom_doc.rm_cost_as_per == 'Valuation Rate': | ||||
|  | ||||
| @ -334,7 +334,7 @@ class StockEntry(StockController): | ||||
| 
 | ||||
| 			if self.purpose == "Manufacture": | ||||
| 				if validate_for_manufacture: | ||||
| 					if d.is_finished_item or d.is_scrap_item: | ||||
| 					if d.is_finished_item or d.is_scrap_item or d.is_process_loss: | ||||
| 						d.s_warehouse = None | ||||
| 						if not d.t_warehouse: | ||||
| 							frappe.throw(_("Target warehouse is mandatory for row {0}").format(d.idx)) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user