How i can change validation for duplicate item in purchase order

Hi,

now in purchase or sales order the same item can be entered twice if
the description is different , but now i want the same item can be
entered twice as long as a certain field is diffenrent each for
another…
in my case the filed is SPK filed , SPK is an item request code (its different with MREQ or PROD)…

it said i need to chenge the validate code in this thread Duplicate item in purchase order

but i think im not supposed to change erpnext code…and i think if i do in
validate hook than my code is being run after the original so its should
be raise and error first before my code run…is there any method i can
overide ?

please some advise

Please don’t create new threads on the same topic!

You should edit the validation function to allow duplication if any field (other than row index and creation / modified timestamps) is different and send a PR.