def req_items_for_inv(site_id, quantity_type):
 if (not settings.has_module('req')):
  return Storage()
 table = s3db.req_req
 itable = s3db.req_req_item
 query = (((((((table.site_id == site_id) & (table.id == itable.req_id)) & (itable.item_pack_id == itable.item_pack_id)) & (itable[('quantity_%s' % quantity_type)] < itable.quantity)) & (table.cancel == False)) & (table.deleted == False)) & (itable.deleted == False))
 req_items = db(query).select(itable.id, itable.req_id, itable.item_id, itable.quantity, itable[('quantity_%s' % quantity_type)], itable.item_pack_id, orderby=(table.date_required | table.date))
 req_item_ids = []
 unique_req_items = Storage()
 for req_item in req_items:
  if (req_item.item_id not in req_item_ids):
   unique_req_items[req_item.item_id] = Storage(req_item.as_dict())
   req_item_ids.append(req_item.item_id)
 return unique_req_items

def req_items_for_inv ( site_id , quantity_type ) : if ( not settings . has_module ( 'req' ) ) : return Storage ( ) table = s3db . req_req itable = s3db . req_req_item query = ( ( ( ( ( ( ( table . site_id == site_id ) & ( table . id == itable . req_id ) ) & ( itable . item_pack_id == itable . item_pack_id ) ) & ( itable [ ( 'quantity_%s' % quantity_type ) ] < itable . quantity ) ) & ( table . cancel == False ) ) & ( table . deleted == False ) ) & ( itable . deleted == False ) ) req_items = db ( query ) . select ( itable . id , itable . req_id , itable . item_id , itable . quantity , itable [ ( 'quantity_%s' % quantity_type ) ] , itable . item_pack_id , orderby = ( table . date_required | table . date ) ) req_item_ids = [ ] unique_req_items = Storage ( ) for req_item in req_items : if ( req_item . item_id not in req_item_ids ) : unique_req_items [ req_item . item_id ] = Storage ( req_item . as_dict ( ) ) req_item_ids . append ( req_item . item_id ) return unique_req_items
used by recv_process & send_process returns a dict of unique req items key = item_id .