This question has been flagged
2045 Views

Hello!!

Please, i work with on_change and get_inputs.

Here is my code:

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)]}"/>

My question is that, before i click on the convention_ids field the get_inputs functions and give me all the values??

Please, who can help?!

Thanks a lot in advance.

Avatar
Discard