'Record creation post-processing
If the added organisation is the lead role, set the
project.organisation to point to the same organisation
& update the realm_entity.'

@staticmethod
def project_organisation_onaccept(form):

    vars = form.vars
    if (str(vars.role) == str(current.deployment_settings.get_project_organisation_lead_role())):
        db = current.db
        ltable = db.project_organisation
        record = db((ltable.id == vars.id)).select(ltable.project_id, ltable.organisation_id, limitby=(0, 1)).first()
        organisation_id = record.organisation_id
        ptable = db.project_project
        db((ptable.id == record.project_id)).update(organisation_id=organisation_id, realm_entity=current.s3db.pr_get_pe_id('org_organisation', organisation_id))
