2
我在表单中创建了一个带有chatter的自定义模块。openerp Message_post error..NameError:没有定义全局名称'_'
我想发布自定义消息。但我得到以下错误。
File "/opt/openerp/my_modules/forum/forum.py", line 22, in function_which_post_msg
self.message_post(cr, uid, ids, body=_("New Question has been <b>created</b>"), context=context)
NameError: global name '_' is not defined
我.py文件是
import datetime
import time
import openerp
from openerp.osv import osv, fields
class Course(osv.osv):
_name = "forum.course"
_inherit = ['mail.thread', 'ir.needaction_mixin']
_columns = {
'name' : fields.char(string="Question Title", size=256, required=True),
'description' : fields.text(string="Question Description", required=True),
}
def function_which_post_msg(self, cr, uid, ids, context=None):
self.message_post(cr, uid, ids, body=_("New Question has been <b>created</b>"), context=context)
def create(self, cr, uid, ids, context=None):
self.function_which_post_msg(cr, uid, ids, context=context)
有没有解决你的错误?使用此导入? –
_错误已解决,但出现跟踪错误。 文件 “/opt/openerp/my_modules/forum_nyros/forum.py”,第24行,在function_which_post_msg self.message_post(CR,UID,IDS,身体= _( “新问题一直创建”), context = context) 文件“/opt/openerp/addons/mail/mail_thread.py”,第1023行,在message_post “无效的thread_id;应该是0,False,一个ID或带有一个ID的列表” – user2088432
能否请您提出新的问题?所以不要重叠这个问题标题。并接受这个答案。谢谢 –