Auto generate unique product code if not provided

http://manage.dimagi.com/default.asp?121783
Boy scout rule, on it.