Auto Generate unique text

I have a field (Customer Code and Customer Name) in my account module. My question is if Customer Name is Om Kumar then I want that automatic a unique code generated like OM01 and store in Customer Code. If OM01 already exits then it automatically created OM02.

You could do a after_save logic hook to do that; whenever the customer name is updated, execute that logic you describe in PHP.