global name '_' is not defined

Asked by Marija Cosic

Hi,
I have this error:
  File "D:\FON\bin\netsvc.py", line 247, in dispatch
    result = LocalService(service_name)(method, *params)
  File "D:\FON\bin\netsvc.py", line 76, in __call__
    return getattr(self, method)(*params)
  File "D:\FON\bin\service\web_services.py", line 577, in execute
    res = service.execute(db, uid, object, method, *args)
  File "D:\FON\bin\osv\osv.py", line 58, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "D:\FON\bin\osv\osv.py", line 119, in execute
    res = pool.execute_cr(cr, uid, obj, method, *args, **kw)
  File "D:\FON\bin\osv\osv.py", line 111, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "d:\FON\bin\addons\petty_cash\ptc_daily_journal.py", line 71, in create
    raise osv.except_osv(_('Error !'), _('There is no required course for the currency - the date.'))
NameError: global name '_' is not defined

What is the problem here?

Question information

Language:
English Edit question
Status:
Answered
For:
Odoo Addons (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:

This question was originally filed as bug #612892.

Revision history for this message
Anup(SerpentCS) (anup-serpent) said :
#1

Hello Marija Cosic,

   _() method is used to translate the string. It is not defined in your python file. You need to import the _() method from tools. Write "from tools.translate import _ " and this error wont show up.
  Hope this helps.

Thanks.

Revision history for this message
Marija Cosic (cosicmarija) said :
#2

Thank you very much. This was very useful. My job has been done. :)
Best regards,
Marija

Can you help with this problem?

Provide an answer of your own, or ask Marija Cosic for more information if necessary.

To post a message you must log in.