Hello all,
I have added a field for salary structure in my form and added line level for salary rules.. i want that when i select a particular salary structure then all attached rules of this structure should be listed in line level...
Here is my code:
@api.onchange('salary_structure')
def _get_structure_head(self):
self.settlement_detail_ids = [(5, _, _)]
if self.salary_structure:
object1 = self.env['hr.payroll.structure'].search([('id', '=', self.salary_structure.id)])
self.settlement_detail_ids.unlink()
for r1 in object1:
object2 = self.env['hr.salary.rule'].search([('structure_id', '=', r1.id)])
for r2 in object2:
self.settlement_detail_ids |= self.settlement_detail_ids.new({
'head': r2.id
})