是什么让 on-change 在点击之前起作用?
What makes an on-change functions before clicking?
拜托,我与 on_change 和 get_inputs 一起工作。
这是我的代码:
PYTHON:
def get_inputs(self, cr, uid,ids, convention_id, company_id, context=None):
ret = []
if convention_id == False:
My_error_Msg = 'Please, select your CONVENTION'
raise osv.except_osv(_("Error!"), _(My_error_Msg))
return False
else:
obj = self.pool.get('seetek.convention.categorie.line')
obj_ids = obj.search(cr, uid, [('convention_id', '=', convention_id)])
res = obj.read(cr, uid, obj_ids, ['nom','nature','id'], context)
for r in res :
inputs = {
'company_convention_categorie_id': r['id'],
'company_id': company_id,
'nom': r['nom'],
'nature': r['nature'],
'actif': True,
}
ret.append(inputs)
return ret
def on_change_convention_id(self, cr, uid, ids, convention_id, company_id, context=None):
res = {'value':{line_ids': self.get_inputs(cr, uid, ids, convention_id, company_id, context=context),
}
}
return res
XML:
<field name="convention_ids" on_change="on_change_convention_id(convention_ids,company_ids)" attrs="{'invisible': [('company_ids','=',False)]}"/>
我的问题是,在我单击 convention_ids 字段之前,get_inputs 函数并提供所有值??
请问,谁能帮忙?!
我找到了解决问题的方法。
事实上 get_inputs 功能是完美的,没有任何问题。
使问题来的issue在on_change。
Si 我已经将它更改为下面的代码并且它完美地工作:
def on_change_conventions_id(self, cr, uid, ids, convention_id, company_id, context=None):
if company_id == False:
My_error_Msg = 'Please, select your COMPANY'
raise osv.except_osv(_("Error!"), _(My_error_Msg))
else:
print company_id
print convention_id
res = {'value':{'seetek_line_ids': self.get_inputs(cr, uid, ids, convention_id, company_id, context=context),
}
}
return res
非常感谢和问候:)
拜托,我与 on_change 和 get_inputs 一起工作。
这是我的代码:
PYTHON:
def get_inputs(self, cr, uid,ids, convention_id, company_id, context=None):
ret = []
if convention_id == False:
My_error_Msg = 'Please, select your CONVENTION'
raise osv.except_osv(_("Error!"), _(My_error_Msg))
return False
else:
obj = self.pool.get('seetek.convention.categorie.line')
obj_ids = obj.search(cr, uid, [('convention_id', '=', convention_id)])
res = obj.read(cr, uid, obj_ids, ['nom','nature','id'], context)
for r in res :
inputs = {
'company_convention_categorie_id': r['id'],
'company_id': company_id,
'nom': r['nom'],
'nature': r['nature'],
'actif': True,
}
ret.append(inputs)
return ret
def on_change_convention_id(self, cr, uid, ids, convention_id, company_id, context=None):
res = {'value':{line_ids': self.get_inputs(cr, uid, ids, convention_id, company_id, context=context),
}
}
return res
XML:
<field name="convention_ids" on_change="on_change_convention_id(convention_ids,company_ids)" attrs="{'invisible': [('company_ids','=',False)]}"/>
我的问题是,在我单击 convention_ids 字段之前,get_inputs 函数并提供所有值??
请问,谁能帮忙?!
我找到了解决问题的方法。 事实上 get_inputs 功能是完美的,没有任何问题。 使问题来的issue在on_change。 Si 我已经将它更改为下面的代码并且它完美地工作:
def on_change_conventions_id(self, cr, uid, ids, convention_id, company_id, context=None):
if company_id == False:
My_error_Msg = 'Please, select your COMPANY'
raise osv.except_osv(_("Error!"), _(My_error_Msg))
else:
print company_id
print convention_id
res = {'value':{'seetek_line_ids': self.get_inputs(cr, uid, ids, convention_id, company_id, context=context),
}
}
return res
非常感谢和问候:)