'A track item can only be deleted if the status is Preparing
When a track item record is deleted and it is linked to an inv_item
then the inv_item quantity will be reduced.'

@staticmethod
def inv_track_item_deleting(id):

    db = current.db
    s3db = current.s3db
    tracktable = db.inv_track_item
    inv_item_table = db.inv_inv_item
    ritable = s3db.req_req_item
    siptable = db.supply_item_pack
    record = tracktable[id]
    if (record.status != 1):
        return False
    if record.req_item_id:
        req_id = record.req_item_id
        req_item = ritable[req_id]
        req_quantity = req_item.quantity_transit
        req_pack_quantity = siptable[req_item.item_pack_id].quantity
        track_pack_quantity = siptable[record.item_pack_id].quantity
        quantity_transit = s3db.supply_item_add(req_quantity, req_pack_quantity, (- record.quantity), track_pack_quantity)
        db((ritable.id == req_id)).update(quantity_transit=quantity_transit)
        s3db.req_update_status(req_id)
    if record.send_inv_item_id:
        trackTotal = record.quantity
        db((inv_item_table.id == record.send_inv_item_id)).update(quantity=(inv_item_table.quantity + trackTotal))
        db((tracktable.id == id)).update(quantity=0, comments=('%sQuantity    was:    %s' % (inv_item_table.comments, trackTotal)))
    return True
