'When a Task is linked to an IReport, then populate the location_id'

@staticmethod
def task_ireport_onaccept(form):

    vars = form.vars
    ireport_id = vars.ireport_id
    task_id = vars.task_id
    db = current.db
    table = db.project_task
    query = (table.id == task_id)
    record = db(query).select(table.location_id, limitby=(0, 1)).first()
    if ((not record) or record.location_id):
        return
    itable = db.irs_ireport
    query = (itable.id == ireport_id)
    record = db(query).select(itable.location_id, limitby=(0, 1)).first()
    if ((not record) or (not record.location_id)):
        return
    location_id = record.location_id
    query = (table.id == task_id)
    db(query).update(location_id=location_id)
