Skip to Content
Menu
This question has been flagged
1 Reply
362 Views

Hi!!!

Please who can help me i need it so much please.

Look I want to get two fields from the same table which is hr_employee. The two fields are: employee_id, id. And i want to make an onchange when i select the employee_id (name) i want to get the id. Please help

Avatar
Discard
Best Answer


def on_change_cm_id(self,cr, uid, ids,cm_id,context=None):

     context=context or {}

     attributes_product_template = []

     value = {}

     if ids:

         old_note_ids = self.pool.get('product.attribute.line').search(cr, uid,[('product_tmpl_id','in',ids)])

         self.pool.get('product.attribute.line').unlink(cr, uid, old_note_ids)

     attribute_cm_ids = []

     attribute_cm_ids = self.pool.get('attribute.comun.denominador.line').search(cr, uid, [('comun_denominador_id', '=', cm_id)]) 

     for attribute_id in self.pool.get('attribute.comun.denominador.line').read(cr, uid, attribute_cm_ids, ['attribute_comun_denominador_id', 'value_comun_denominador_ids']):

         attributes_product_template.append((0,0,{'value_ids':attribute_id['value_comun_denominador_ids'],'attribute_id':attribute_id['attribute_comun_denominador_id'][0]}))

     value.update(attribute_line_ids=attributes_product_template)

     return {'value':value}


In for loop, I acces two diferent fields, I use for loop because Im populating one2many and many2many field. Note that in arguments  of my on_change function, I have cm_id as parameter, in your case would be employee_id.


Hope this help you

Avatar
Discard
Related Posts Replies Views Activity
3
Sep 18
5414
0
Feb 16
3533
0
Aug 15
5369
3
Mar 15
367
1
Mar 15
4404