def req_item_onaccept(form):
 form_vars = form.vars
 req_id = form_vars.get('req_id', None)
 if (not req_id):
  req_id = s3_get_last_record_id('req_req')
 if (not req_id):
  raise HTTP(500, 'Cannot get req_id')
 req_update_status(req_id)
 item_id = form_vars.get('item_id', None)
 db = current.db
 citable = db.supply_catalog_item
 cats = db((citable.item_id == item_id)).select(citable.item_category_id)
 rictable = db.req_req_item_category
 for cat in cats:
  item_category_id = cat.item_category_id
  query = (((rictable.deleted == False) & (rictable.req_id == req_id)) & (rictable.item_category_id == item_category_id))
  exists = db(query).select(rictable.id, limitby=(0, 1))
  if (not exists):
   rictable.insert(req_id=req_id, item_category_id=item_category_id)

def req_item_onaccept ( form ) : form_vars = form . vars req_id = form_vars . get ( 'req_id' , None ) if ( not req_id ) : req_id = s3_get_last_record_id ( 'req_req' ) if ( not req_id ) : raise HTTP ( 500 , 'Cannot get req_id' ) req_update_status ( req_id ) item_id = form_vars . get ( 'item_id' , None ) db = current . db citable = db . supply_catalog_item cats = db ( ( citable . item_id == item_id ) ) . select ( citable . item_category_id ) rictable = db . req_req_item_category for cat in cats : item_category_id = cat . item_category_id query = ( ( ( rictable . deleted == False ) & ( rictable . req_id == req_id ) ) & ( rictable . item_category_id == item_category_id ) ) exists = db ( query ) . select ( rictable . id , limitby = ( 0 , 1 ) ) if ( not exists ) : rictable . insert ( req_id = req_id , item_category_id = item_category_id )
update request status update req_item_category link table .