Skip to Content
मेन्यू
This question has been flagged
1 Reply
8220 Views

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
Discard
Best Answer

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
Discard
Author

'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

Related Posts Replies Views Activity
1
मार्च 15
5685
0
जन॰ 17
8775
2
मार्च 15
10311
0
मार्च 15
4996
1
मार्च 15
4354