跳至内容
菜单
此问题已终结
1 回复
382 查看

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

形象
丢弃
最佳答案


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

形象
丢弃
相关帖文 回复 查看 活动
3
9月 18
5433
0
2月 16
3553
0
8月 15
5387
3
3月 15
375
1
3月 15
4418