Kvvaradha describes the generalized approach (making item code a reference, thus reusing existing code). This would be a great addition to the base, and assuming your part numbers are numeric, would be easy to implement, using the {1} definition. If they are not strictly numeric, you would have to add the meta code to handle those fields.
The quick and dirty approach is what I did in my fork. This hard codes an assumption of how item codes are formatted, and may need to changed depending on how your item codes are formatted. In my case, they have an alpha prefix and a numeric suffix.
inventory/manage/items.php
function item_settings(&$stock_id, $new_item)
{
...
if ($new_item)
{
$tmpCodeID=next_stock_id();
...
function numeric_offset($text) {
preg_match('/\d/', $text, $m, PREG_OFFSET_CAPTURE);
if (sizeof($m))
return $m[0][1];
// the case when there's no numbers in the string
return strlen($text);
}
/*
This function returns the next unused stock_id in stock_master.
To work correctly, stock_ids should be numeric or end in a numeric.
*/
function next_stock_id() {
$sql = "SELECT max(stock_id) as max FROM ".TB_PREF."stock_master";
$result = db_query($sql, "Can not find max stock_id");
$row = db_fetch_row($result);
if (!$row[0]) return null;
$offset= numeric_offset($row[0]);
$num=substr($row[0], $offset);
if (!is_numeric($num))
return null;
$num += 1;
return substr($row[0], 0, $offset) . $num;
}