'When an adjustment record is created and it is of type inventory
then an adj_item record for each inv_inv_item in the site will be
created. If needed, extra adj_item records can be created later.'

@staticmethod
def inv_adj_onaccept(form):

    id = form.vars.id
    db = current.db
    inv_item_table = db.inv_inv_item
    adjitemtable = db.inv_adj_item
    adjtable = db.inv_adj
    adj_rec = adjtable[id]
    if (adj_rec.category == 1):
        site_id = form.vars.site_id
        query = (((inv_item_table.site_id == site_id) & (inv_item_table.quantity > 0)) & (inv_item_table.deleted == False))
        row = db(query).select()
        for inv_item in row:
            adjitemtable.insert(reason=0, adj_id=id, inv_item_id=inv_item.id, item_id=inv_item.item_id, item_pack_id=inv_item.item_pack_id, old_quantity=inv_item.quantity, currency=inv_item.currency, old_status=inv_item.status, new_status=inv_item.status, old_pack_value=inv_item.pack_value, new_pack_value=inv_item.pack_value, expiry_date=inv_item.expiry_date, bin=inv_item.bin, old_owner_org_id=inv_item.owner_org_id, new_owner_org_id=inv_item.owner_org_id)
