code: def switch_company(ctx, company):
      
      current_company = ctx.env.user.company_id
      ctx.env.user.company_id = safe_record(ctx, company)
      yield ctx
      ctx.env.user.company_id = current_company
docs: Context manager to switch current company.
  
      Accepts both company record and xmlid.