'Executed when a project organisation record is deleted.
If the deleted organisation is the lead role on this project,
set the project organisation to None.'

@staticmethod
def project_organisation_ondelete(row):

    db = current.db
    potable = db.project_organisation
    ptable = db.project_project
    query = (potable.id == row.get('id'))
    deleted_row = db(query).select(potable.deleted_fk, potable.role, limitby=(0, 1)).first()
    if (str(deleted_row.role) == str(current.deployment_settings.get_project_organisation_lead_role())):
        deleted_fk = json.loads(deleted_row.deleted_fk)
        project_id = deleted_fk['project_id']
        db((ptable.id == project_id)).update(organisation_id=None)
