【发布时间】:2011-11-24 06:52:36
【问题描述】:
我在 fct1 中有一个变量 var_x。 我想在同一个类的另一个函数 fct2 中使用相同的变量值 代码:
def onchange_blockcreate(self, cr, uid, ids, block):
global family_code_id
global varname
if block:
cr.execute ('select activefrom,activeto from new_block where id=%s ',(block,))
family_code_id =cr.fetchone()[0]
msgalert = {'title':'Warning','message':}
return {'warning':msgalert}
def onchange_evaluation_date(self, cr, uid, ids,family_code_id,activefrom):
print activefrom
print family_code_id
if activefrom>=family_code_id:
print activefrom
else :
msgalert = {'title':'Warning','message':'fieldtocheck is too short!'}
return {'warning':msgalert}
这里family_code_id 用于第一个函数,我也想在第二个函数中使用相同的family_code_id。但它显示一个错误:
全局变量 family_code_id 未定义。
这在 openerp 中怎么可能?
【问题讨论】:
-
请修正您的代码格式。每个缩进使用 4 个空格。不要混用制表符和空格。
标签: python openerp postgresql-9.1