'Represent an item entity in option fields or list views
- unused, we use VirtualField instead
@ToDo: Migrate to S3Represent'

@staticmethod
def item_represent(id):

    if (not id):
        return current.messages['NONE']
    db = current.db
    if (isinstance(id, Row) and ('instance_type' in id)):
        item = id
        instance_type = item.instance_type
    else:
        item_table = db.supply_item_entity
        item = db((item_table._id == id)).select(item_table.instance_type, limitby=(0, 1)).first()
        try:
            instance_type = item.instance_type
        except:
            return current.messages.UNKNOWN_OPT
    T = current.T
    if (instance_type == 'inv_inv_item'):
        item_str = T('In    Stock')
    elif (instance_type == 'inv_track_item'):
        s3db = current.s3db
        itable = s3db[instance_type]
        rtable = s3db.inv_recv
        query = ((itable.item_entity_id == id) & (rtable.id == itable.recv_id))
        eta = db(query).select(rtable.eta, limitby=(0, 1)).first().eta
        item_str = (T('Due    %(date)s') % dict(date=eta))
    else:
        return current.messages.UNKNOWN_OPT
    return item_str
