'Update all ancestor fields from immediate parent
Update Status of Criterion'

def project_criteria_activity_onaccept(self, form, create=False):

    form_vars = form.vars
    criteria_id = form_vars.get('criteria_id')
    if criteria_id:
        db = current.db
        s3db = current.s3db
        record_id = form_vars.id
        table = s3db.project_criteria_activity
        ctable = s3db.project_indicator_criteria
        criterion = db((ctable.id == criteria_id)).select(ctable.id, ctable.goal_id, ctable.outcome_id, ctable.output_id, ctable.indicator_id, limitby=(0, 1)).first()
        if criterion:
            db((table.id == record_id)).update(goal_id=criterion.goal_id, outcome_id=criterion.outcome_id, output_id=criterion.output_id, indicator_id=criterion.indicator_id)
            if (not create):
                query = (((table.criteria_id == criteria_id) & (table.deleted == False)) & (table.id != record_id))
                records = db(query).select(table.weighting)
                total = 0
                for r in records:
                    total += r.weighting
                total += form_vars.weighting
                if (total != 1.0):
                    current.response.warning = current.T('Weightings    should    add    up    to    1.0')
    if current.deployment_settings.get_project_status_from_activities():
        row = db((table.id == record_id)).select(table.project_id, limitby=(0, 1)).first()
        try:
            project_id = row.project_id
        except:
            current.log.error('Cannot    find    Project    record    (no    record    for    this    ID),    so    cannot    update    statuses')
        else:
            self.project_planning_status_update(project_id)
