How to create a special autoincrement field? I have a "Property" content type created for a real estate web site. The Property content type has a taxonomy field called "Type" where type can be House, Office, Apartment and so on...

I want to create a "code" field that has to be something like "H-1" where H is for Home and 1 must be an incremental number, so houses will have each a different code: "H-1", "H-2", "H-3" ... "H-188", etc. And so on for Offices "O-1", "O-2"..."O-479". I see that there is a Serial module, but that module helps me only creating autoincremental numbers for each content type, not based on other fields of that content type.

I was planning to use auto_nodetitle + serial module + rules to create the letter+number format for my field, but I will have the same problem: If I create "H-1" and then create an Office, it will have "O-2" code, and not "O-1" code.

Is there a module than can help me? If not, how can I make it?
The obvious option would be to have a serial field for each type. Whether or not that is feasible based on your business rules (are there lots of types, are the types likely to change, etc.) is another question.

Another module that may be very useful in these types of problems is the computed field module.

Another option (probably the one I would choose) is to make it completely custom.
Either a custom entity property or a custom field of some sort that does database queries to determine the next value instead of auto_nodetitle + serial module + rules.
Be careful of race conditions when doing something like this though.