def send_returns():

    try:
        send_id = request.args[0]
    except:
        redirect(f="send")

    stable = s3db.inv_send
    if not auth.s3_has_permission("update", stable, record_id=send_id):
        session.error = T("You do not have permission to return this sent shipment.")

    send_record = db(stable.id == send_id).select(stable.status,
                                                  limitby=(0, 1)
                                                  ).first()
    inv_ship_status = s3db.inv_ship_status
    if send_record.status == inv_ship_status["IN_PROCESS"]:
        session.error = T("This shipment has not been sent - it cannot be returned because it can still be edited.")

    if session.error:
        redirect(URL(c="inv", f="send",
                     args=[send_id]))

    rtable = s3db.inv_recv
    tracktable = s3db.inv_track_item

    # Okay no error so far, change the status to Returning
    stable[send_id] = dict(status = inv_ship_status["RETURNING"],
                           owned_by_user = None,
                           owned_by_group = ADMIN)
    recv_row = db(tracktable.send_id == send_id).select(tracktable.recv_id,
                                                        limitby = (0, 1)).first()
    if recv_row:
        recv_id = recv_row.recv_id
        rtable[recv_id] = dict(date = request.utcnow,
                               status = inv_ship_status["RETURNING"],
                               owned_by_user = None,
                               owned_by_group = ADMIN)
    # Set all track items to status of returning
    db(tracktable.send_id == send_id).update(status = s3db.inv_tracking_status["RETURNING"])
    session.confirmation = T("Sent Shipment has returned, indicate how many items will be returned to Warehouse.")

    redirect(URL(c="inv", f="send",
                 args=[send_id, "track_item"]))

# -----------------------------------------------------------------------------
Tests that a simple repo url is correctly recognized.
dataset/ETHPy150Open sahana/eden/controllers/inv.py/send_returns--crossover with--dataset/ETHPy150Open pebble/cloudpebble/ide/tests.py/UrlToReposTest.test_basic_url_to_repo