'Onaccept-routine for seized items:
- set returned_on and returned_by if status=="RET"'

@staticmethod
def seized_item_onaccept(form):

    db = current.db
    s3db = current.s3db
    formvars = form.vars
    try:
        record_id = formvars.id
    except AttributeError:
        return
    table = s3db.security_seized_item
    query = ((table.id == record_id) & (table.deleted == False))
    record = db(query).select(table.id, table.status, table.returned_on, table.returned_by, limitby=(0, 1)).first()
    if (not record):
        return
    if (record.status == 'RET'):
        if ((not record.returned_on) and (not record.returned_by)):
            now = current.request.utcnow.date()
            logged_in_person = current.auth.s3_logged_in_person()
            record.update_record(returned_on=now, returned_by=logged_in_person)
    else:
        record.update_record(returned_on=None, returned_by=None)
