Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • eLearning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Conocimientos
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Alimentación y hostelería
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Browse all Industries
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Services for Partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar una demostración
  • Precios
  • Ayuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyecto
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

How to get the job_id of the user_id

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
hrres.user
2 Respuestas
10690 Vistas
Avatar
Lisa Kain

How to get the job_id of the user_id linked to the employee_id

0
Avatar
Descartar
Avatar
Niyas Raphy (Walnut Software Solutions)
Mejor respuesta

Hi,

If you have a user id with you, then if you wan to find the job _id of the employee whose related user is this user_id, you can do like this,

suppose uid has the id of the user, then

employee_rec = self.env['hr.employee'].search([('user_id', '=', uid)])
job_id = employee_rec.job_id.id

If the user is assigned to more than one employee, then you have to use for loop to iterate over the employee_rec or use limit=1 in search condition.

If you have the employee id with you, then you can get the job id easily , let emp_id is the id of employee

employee_rec = self.env['hr.employee'].search([('id', '=', emp_id)])
job_id = employee_rec.job_id.id

To get the current user name and his job name in the qweb , try the below code.

<span t-esc="user.name"/>
<t t-foreach="request.env['hr.employee'].search([('user_id', '=', user.id)])" t-as="obj">
<t t-esc="obj.job_id.name"/>
</t>

Thanks


3
Avatar
Descartar
Avatar
Lisa Kain
Autor Mejor respuesta

I have this NameError: name 'self' is not defined

my_employee = self.env['hr.employee'].search([('user_id', '=', create_uid)])

my_job_id = my_employee.job_id.id
0
Avatar
Descartar
Niyas Raphy (Walnut Software Solutions)

From where you calling this code ? Try to print self and see whats there in it

Lisa Kain
Autor

class PurchaseOrder(models.Model):

_inherit = 'purchase.order'

my_employee = self.env['hr.employee'].search([('user_id', '=', create_uid)])

my_job_id = my_employee.job_id.id

Niyas Raphy (Walnut Software Solutions)

only this much lines ? can you add the full code in this class ? not defined any function ?

Lisa Kain
Autor

yes only this much lines! and no i dont defined any function!!! i'm just trying something fast and want to get the job id but im looking for xml solution too if you can help

Lisa Kain
Autor

i need to give job_id to this <span t-field="o.create_uid.name"/>

Niyas Raphy (Walnut Software Solutions)

Actually you can't do it like this,

Niyas Raphy (Walnut Software Solutions)

can you tell what exactly you are looking for

Lisa Kain
Autor

in a report i want to mention the user who created it and his job

Niyas Raphy (Walnut Software Solutions)

For getting the current user name and his job name, you try this,

<span t-esc="user.name"/>

<t t-foreach="request.env['hr.employee'].search([('user_id', '=', user.id)])" t-as="obj">

<t t-esc="obj.job_id.name"/>

</t>

Lisa Kain
Autor

it works so nice! thank you so much

¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
Attendance Analysis – How to calculate Extra Hours with flexible start times
hr
Avatar
Avatar
2
oct 25
764
block other users from editing a survey
hr
Avatar
Avatar
1
oct 25
760
re assign the leave request to the leave manager and notify him by email
hr
Avatar
Avatar
1
sept 25
723
Time off - different timezone message
hr
Avatar
Avatar
Avatar
3
sept 25
979
Template Job page
hr
Avatar
Avatar
1
ago 25
1003
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información legal • Privacidad
  • Seguridad
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y totalmente integrado.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now