for record in self:
record['x_state'] = self.env['hr.payslip.run'].search([('payroll_period.name','=',record.first_open_period_name),('pgroup_id.payroll_group_id','=',record.id)],order='id desc')[0].state
for record in self:
record ['x_state'] = self.env ['hr.payslip.run'] .search( [('payroll_period.name','=',record.first_open_period_name),('pgroup_id.payroll_group_id','=',record.id)] ,order='id desc') [0] .state