Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
8208 Vistas

in my onchange line items get changed.,if there is no value,the previous onchange value still can u plz help me

here is my onchange function:

 def get_salary_line(self, cr, uid, ids, emp_id, context = None):
        hr_payslip_id = self.pool.get('hr.payslip').search(cr, uid, [('employee_id','=',emp_id)], context = context)
        res= []
        for payslip_obj in self.pool.get('hr.payslip').browse(cr, uid, hr_payslip_id, context = context):
            line_ids2 = []
            res = {'value':{
                      'allowance_line_ids':[],
                      
                      }
            } 
           
            for line in payslip_obj.line_ids:
                if line.category_id:
               
                    vals = {
                                'name': line.name,
                                'code':line.code,
                                'category_id':line.category_id and line.category_id.id,
                                'contract_id':ids
                                }
                    if line.code !='BASIC' and line.code !='NET' and line.code !='GROSS':
                        line_ids2.append(vals)
                else:
                    print 'haiiiiiiiiiiiiisddffffffffffffffffffffffffffffffffffffffffffffffffffffff'       
                 
        
            res['value'].update({
                    'allowance_line_ids': line_ids2,
                    })
            
        return res

Avatar
Descartar
Mejor respuesta

Hi,

Yes you can unlink o2m records from onchange...

 

Instead of this:

res = {'value':{     'allowance_line_ids':[],     }

Rewite this

res = {'value':{

          'allowance_line_ids': map(lambda x: (2,x), [x.id for x in ALLOWANCE_LINE_IDS]),    

    }

 

Note:

For O2M :: (2, ID) will remove and delete the linked record with id = ID (calls unlink on ID, that will delete the object    completely, and the link to it as well)...

Refer this: Doc

 

 

 

Avatar
Descartar
Autor

'allowance_line_ids': map(lambda x: (2,x), [x.id for x in ALLOWANCE_LINE_IDS]), how can we get this ALLOWANCE_LINE_IDS? ALLOWANCE_LINE_IDS=self.browse(cr, uid, ids, context=context).allowance_line_ids is that right? but my onchange has no effect

Publicaciones relacionadas Respuestas Vistas Actividad
1
mar 15
5678
0
ene 17
8752
2
mar 15
10300
0
mar 15
4986
1
mar 15
4345