我在fct1中有一个变量var_x。 我想在另一个函数fct2在同一类 代码使用相同的变量值:如何在openerp中的同一类的另一个函数中使用一个函数变量?
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也。但它显示一个错误:
global variable family_code_id is not defined.
这是怎么可能在openerp?
retrive在任何类中的函数,数据请修正你的代码的格式。每个缩进使用4个空格。不要混合标签和空格。 – eryksun