我在sale.py中添加了以下代码,但我无法看到打印输出 server.log中。我希望通过返回此函数的列表来填充one2many字段
def model_id_change(self,cr,uid,ids,model_id,context=None):
list1=[]
if context is None:
context = {}
print "Hi"
print str(model_id)
if not model_id:
raise osv.except_osv(_('No Model Selected !'),_('You have to select Model.'))
querystr = 'SELECT microswitch FROM product_model WHERE id = ' + model_id
print querystr
try:
cr.execute(querystr)
s=cr.fetchone()
print s
list1=[]
print list1
for t in s.split(','):
if t:
list1.append(t)
except:
exceptionType, exceptionValue, exceptionTraceback = sys.exc_info()
return(list1)
答案 0 :(得分:0)
print语句打印到标准输出。如果要在服务器日志中获取某些内容,请使用日志记录模块。
import logging
logger = logging.getLogger(__name__)
logger.info('my message, with a substituted variable %s', s)