How to override default functions of erpnext from custom app

Hi,
I want to change the function of how item name for variants is calculated its based on abbrevation but i want it based on attribute value how to achieve it or override the function in item_variant.py file
item_variant.py

How can i achieve this?

hello @Mohammed_Anas1 it would be better if you could provide an example to clarify the problem you facing and why you want to use the attributes over abbreviation

When creating Item using item variants by default it uses attribute abbrevation for item code and item name
for item name i want it by attribute value
the abbr will have some code so when the user is placing order in po or so then they cant remeber code every time so if its the value its easy to understand and with less error the flow can work

Options for overriding a Python function:

  1. If it is a whitelisted method, use the override_whitelisted_methods hook.
  2. If it is a standard doctype classes , use override_doctype_class hook.
  3. For document methods and events, use doc_events hook.
  4. If it falls outside these options, you can use monkey patching. Frappe Monkey Patching Guide: Overriding/Change Core Code Without Touching it

is that what you mean that how it looks items created based on variants when you placing PO

if you want to let the name generated by the Attribute Value without any coding just give the Abbreviation value the same value of the Attribute unless you want to keep the Abbr so there are to many ways to do that as @Ayesha_F mention using one of the override hooks in a custom app if no custom app so that need a work around with a server script using a Doctype Event and make the reference to the Item Doctype and the event will be Before_save or Before_insert i hope that helps

@Ayesha_F used override_whitelisted_methods and it worked perfectly — thank you!
Also, thanks to @Gharieb for the support :raising_hands: