Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita 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
  • Proyectos
  • 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

Syncing model updates

Suscribirse

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

Se marcó esta pregunta
res.partnerhr_employeeodoo17
1524 Vistas
Avatar
Thom Simbeye

I have made a link between contacts and the employee model; customised the create and write functions. I want to ensure that when basic details such as name, phone, mobile, and email are synced between the two records when updated from either side. Current the updates are working after a few attempts thereafte they stop because the context is not being updated properly and causing a recursion error.


The write code in the extended hr.employee

def write(self, vals):

        # Avoid recursion if the update is already in progress

        if self.env.context.get('skip_partner_update', False):

            return super(HrEmployee, self).write(vals)


        # Proceed with the write operation

        res = super(HrEmployee, self).write(vals)


        # Fields to synchronize with partner

        fields_to_sync = ['name', 'phone', 'mobile', 'email', 'job_id']

        related_fields = {

            'name': 'name',

            'phone': 'phone',

            'mobile': 'mobile',

            'email': 'email',

            'job_id': 'job_description',

        }


        # Propagate changes to related partner

        for employee in self:

            if employee.partner_id:

                partner_vals = {related_fields[field]: vals[field] for field in fields_to_sync if field in vals}

                if partner_vals:

                    # Set the context flag to avoid recursion during the partner update

                    employee.partner_id.with_context(skip_employee_update=True).write(partner_vals)


        return res


the write code in the extended res.partner
def write(self, vals):

        # Avoid recursion if the update is already in progress

        if self.env.context.get('skip_employee_update', False):

            return super(ResPartner, self).write(vals)


        # Proceed with the write operation

        res = super(ResPartner, self).write(vals)


        # Fields to propagate to employees

        fields_to_sync = ['name', 'phone', 'mobile', 'email', 'job_description']

        related_fields = {

            'name': 'name',

            'phone': 'work_phone',

            'mobile': 'mobile_phone',

            'email': 'work_email',

            'job_description': 'job_id',

        }


        # Propagate changes to related employees

        for partner in self:

            for employee in partner.employee_ids:

                employee_vals = {related_fields[field]: vals[field] for field in fields_to_sync if field in vals}

                if employee_vals:

                    # Set the context flag to avoid recursion during the employee update

                    employee.with_context(skip_partner_update=True).write(employee_vals)


        return res

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

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

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
Set is_company to True by default Resuelto
res.partner odoo17
Avatar
Avatar
Avatar
Avatar
4
ago 24
2119
Private Information Module HRM
hrmodule hr_employee HRMS odoo17
Avatar
Avatar
1
jul 24
1852
Adding Followers to mail_followers widget automatically from hr.employee
follower res.partner hr_employee mail_thread
Avatar
0
feb 16
7091
Error while posting invoice to ZATCA odoo sh Resuelto
odoo17
Avatar
Avatar
Avatar
Avatar
3
jul 25
3037
How to send a real-time notification to POS UI using bus.bus in Odoo 17?
odoo17
Avatar
Avatar
1
jun 25
5105
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • 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 estar 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