NameError: name '_' is not defined

I was trying to build a report for library transaction by using script report.

Here is my “library repo” script report.

Where Library Transaction is DocType and his DocFields are:
transaction_type, transaction_date, article… etc.

I try to write simple python script in library_repo.py for testing which is

def execute(filters=None):
columns = [
{
‘fieldname’: ‘transaction_type’,
‘label’: _(‘Transaction Type’),
‘fieldtype’: ‘Data’,

    },
]

data = [
	{
		'transaction_type': 'Return',
	},
	{
		'transaction_type': 'Issue',
	},
]

return columns, data

But when i click the “show report” button a server error was shown.
The error is : NameError: name ‘_’ is not defined

I can’t figure why this error occur. Please help me for solving this error.

Note: My developer mode is 1.

Include in your .py
from frappe import _
If that’s what i quite understood from the error

1 Like

Thanks. Problem solved

1 Like