'Update the Commit Status for the Request Item & Request'

@staticmethod
def commit_item_onaccept(form):

    db = current.db
    req_item_id = form.vars.req_item_id
    ritable = db.req_req_item
    req = db((ritable.id == req_item_id)).select(ritable.req_id, limitby=(0, 1)).first()
    if (not req):
        return
    req_id = req.req_id
    query = ((ritable.req_id == req_id) & (ritable.deleted == False))
    ritems = db(query).select(ritable.id, ritable.item_pack_id, ritable.quantity)
    ctable = db.req_commit
    citable = db.req_commit_item
    query = (((ctable.req_id == req_id) & (citable.commit_id == ctable.id)) & (citable.deleted == False))
    citems = db(query).select(citable.item_pack_id, citable.quantity)
    commit_qty = {}
    for item in citems:
        item_pack_id = item.item_pack_id
        if (item_pack_id in commit_qty):
            commit_qty[item_pack_id] += (item.quantity * item.pack_quantity())
        else:
            commit_qty[item_pack_id] = (item.quantity * item.pack_quantity())
    complete = False
    for item in ritems:
        if (item.item_pack_id in commit_qty):
            quantity_commit = commit_qty[item.item_pack_id]
            db((ritable.id == item.id)).update(quantity_commit=quantity_commit)
            req_quantity = (item.quantity * item.pack_quantity())
            if (quantity_commit >= req_quantity):
                complete = True
            else:
                complete = False
    rtable = db.req_req
    if complete:
        db((rtable.id == req_id)).update(commit_status=REQ_STATUS_COMPLETE)
    else:
        db((rtable.id == req_id)).update(commit_status=REQ_STATUS_PARTIAL)
