Exclude one(or more) accounts from Journal Entry

It might sound weird but I was looking for a way to exclude one (or more) account from the journal entry. Suppose I don’t want the Cash account to show up while I am doing a journal entry.

Another case will be I just want Cash and Bank accounts for contra entry. No other accounts should appear for contra entry.

@ag11,

You can write a custom script and add the filters to account field so that is will filter and exclude the account(s).

e.g.

cur_frm.fields_dict.accounts.grid.get_field("account").get_query = function(doc) {
	return {
		filters: {
			'account': ['not in', 'Account A,Account B']
		}
	}
})

Thanks,
Makarand

Thanks Makarand for your help. But can you tell me which doctype I will apply this script?

@ag11,

Add custom script for Journal Entry

Thanks,
Makarand

Returned an almost blank page. The grid is not showing anymore.

@ag11 check your browser’s console for the error log

Uncaught SyntaxError: Unexpected token )
at Class.setup (form.min.js:262)
at _f.Frm.setup (form.min.js:18)
at _f.Frm.refresh (form.min.js:58)
at Class.load (form.min.js:15)
at form.min.js:15
at Object.with_doc (desk.min.js:536)
at Class.show_doc (form.min.js:13)
at form.min.js:10
at Object.with_doctype (desk.min.js:528)
at Class.make (form.min.js:10)

@ag11,

can you share your code?

Thanks, Makarand

The error is gone but with the below script nothing is really hapenning.

cur_frm.fields_dict[“accounts”].grid.get_field(“account”).get_query = function(doc){
return {
filters:{
‘account’: [‘not in’, ‘Cash, Axis Bank’]
}
}
}

Any help on this?