[fix] Validate Company in Account autoname
This commit is contained in:
		
							parent
							
								
									719504a0fe
								
							
						
					
					
						commit
						19fec06366
					
				| @ -19,8 +19,12 @@ class Account(Document): | |||||||
| 			self.get("__onload").can_freeze_account = True | 			self.get("__onload").can_freeze_account = True | ||||||
| 
 | 
 | ||||||
| 	def autoname(self): | 	def autoname(self): | ||||||
| 		self.name = self.account_name.strip() + ' - ' + \ | 		# first validate if company exists | ||||||
| 			frappe.db.get_value("Company", self.company, "abbr") | 		company = frappe.db.get_value("Company", self.company, ["abbr", "name"], as_dict=True) | ||||||
|  | 		if not company: | ||||||
|  | 			frappe.throw(_('Company {0} does not exist').format(self.company)) | ||||||
|  | 
 | ||||||
|  | 		self.name = self.account_name.strip() + ' - ' + company.abbr | ||||||
| 
 | 
 | ||||||
| 	def validate(self): | 	def validate(self): | ||||||
| 		if frappe.local.flags.allow_unverified_charts: | 		if frappe.local.flags.allow_unverified_charts: | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user