Name item according to Item Groups

I’m using v13 ERPNext, so naming series exists.

I wanted the item name to include the item group name:

Here’s what I did:

I created an additional field in the Item Group DocType, “Item Group Code
and then added the same field in the Item DocType and pulled it from the Item Group DocType using fetch from: “item_group.item_group_code”

and then created a new naming series “.{item_group_code}.####.”

How this ideally works:

  1. Case 1

Item Group Name: Raw Material
Item Group Code: RM

when creating a new item it is RM0001, RM0002… and so on…

  1. Case 2

Item Group Name: Consumables
Item Group Code: CNS

when creating a new item it is CNS0001, CNS0002… and so on…

this works when you create an item inside the system from the start i.e. 0001

What I did was used the Bulk Rename tool to rename the items already existing in my system.
But now if I select the naming series while creating a new item in the system, it gives me an error, “item RM0001 already exists”. I tried to update the current value of the naming series but it doesn’t work.

What can be done so that the naming series of the item can actually start from where I left off, in each item group?