def hrm_training_onvalidation(form):
 form_vars = form.vars
 training_event_id = form_vars.get('training_event_id', None)
 if (not training_event_id):
  return
 db = current.db
 table = db.hrm_training_event
 record = db((table.id == training_event_id)).select(table.course_id, table.start_date, table.end_date, table.hours, cache=current.s3db.cache, limitby=(0, 1)).first()
 try:
  form_vars.course_id = record.course_id
  form_vars.date = record.start_date
  form_vars.end_date = record.end_date
  form_vars.hours = record.hours
 except:
  return

def hrm_training_onvalidation ( form ) : form_vars = form . vars training_event_id = form_vars . get ( 'training_event_id' , None ) if ( not training_event_id ) : return db = current . db table = db . hrm_training_event record = db ( ( table . id == training_event_id ) ) . select ( table . course_id , table . start_date , table . end_date , table . hours , cache = current . s3db . cache , limitby = ( 0 , 1 ) ) . first ( ) try : form_vars . course_id = record . course_id form_vars . date = record . start_date form_vars . end_date = record . end_date form_vars . hours = record . hours except : return
if the training is created from a training event .