improve mode_of_payment validate_accounts
using frappe.db.get_value instead of frappe.get_list
This commit is contained in:
		
							parent
							
								
									11f8a0033a
								
							
						
					
					
						commit
						27c266b081
					
				| @ -24,13 +24,5 @@ class ModeofPayment(Document): | |||||||
| 	def validate_accounts(self): | 	def validate_accounts(self): | ||||||
| 		for entry in self.accounts: | 		for entry in self.accounts: | ||||||
| 			"""Error when Company of Ledger account doesn't match with Company Selected""" | 			"""Error when Company of Ledger account doesn't match with Company Selected""" | ||||||
| 			account = frappe.get_list("Account", | 			if frappe.db.get_value("Account", entry.default_account, "company") != entry.company: | ||||||
| 				fields=["name"], |  | ||||||
| 				filters = { |  | ||||||
| 					"company": entry.company, |  | ||||||
| 					"name": entry.default_account |  | ||||||
| 				}) |  | ||||||
| 			try: |  | ||||||
| 				account[0].name |  | ||||||
| 			except IndexError: |  | ||||||
| 				frappe.throw(_("Account does not match with Company")) | 				frappe.throw(_("Account does not match with Company")) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user