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
    • Información
    • 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

Re-usable Server actions in Automation Rules

Suscribirse

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

Se marcó esta pregunta
crmautomatedserver_actionsManufacturing OrderRules
470 Vistas
Avatar
Erik Orehek

Hi all,

Context

  1. Odoo 19 Enterprise.
  2. I want a reusable automation that, when a Manufacturing Order (MO) moves from “Confirmed” to “In Progress”, updates the related CRM Lead/Opportunity to a specific stage.
  3. I may need multiple automations that each move the CRM to different target stages.

Current automated action

  1. Model: Manufacturing Order (mrp.production)
  2. Trigger: State set to “In Progress”
  3. Domain filter: Components Availability = “Available”
  4. Action: Execute Python code:
for mo in records:
    # 1. Find the connected Sales Order (sale.order) by extracting the SO name from the MO's origin.
    # The MO dump shows 'origin: OP/00003 - S00038'. We try to extract 'S00038'.
    so_name = mo.origin.split(' - ')[-1].strip() if mo.origin else False

    if not so_name:
        mo.message_post(body="Warning: Could not extract a Sales Order name from the Manufacturing Order's origin.")
        continue

    SaleOrder = env['sale.order'].search([('name', '=', so_name)], limit=1)

    if not SaleOrder:
        mo.message_post(body=f"Warning: No Sales Order found with name '{so_name}'. Cannot update CRM stage.")
        continue

    # 2. Find the connected CRM Lead/Opportunity (crm.lead)
    # Assumes 'opportunity_id' is the field linking SO to CRM.
    lead = SaleOrder.opportunity_id

    if not lead:
        mo.message_post(body=f"Warning: Sales Order '{SaleOrder.name}' is not linked to a CRM Opportunity/Lead. Cannot update stage.")
        continue

    # 3. Find the 'Waiting spare parts delivery' stage in crm.stage
    target_stage = env['crm.stage'].search([('name', '=', 'Waiting spare parts delivery')], limit=1)

    if not target_stage:
        mo.message_post(body="Warning: Target CRM Stage 'Waiting spare parts delivery' not found. Stage update skipped.")
        continue

    # 4. Update the CRM Lead/Opportunity
    # Writing to the lead directly is simpler than browsing by ID.
    lead.write({'stage_id': target_stage.id})

    # Optional: Log success
    # mo.message_post(body=f"Success: Updated CRM Opportunity '{lead.name}' to stage '{target_stage.name}'.")

What I’d like

  1. Use the same Python once, but pass a different target CRM stage per automation rule. For example when click on "Produced All" (button_mark_done) in MO the CRM status should change to "Finished" stage.

Semi-workaround I have

  1. Create a separate Server Action and call it from each automation with a context param:
destination_stage = "In service"
stage = env['crm.stage'].search([('name', '=', destination_stage)], limit=1)
if not stage:
    raise UserError("CRM Stage '%s' not found." % destination_stage)

env['ir.actions.server'].browse(1124).with_context(
    active_model='mrp.production',
    active_ids=records.ids,
    crm_stage_xmlid=None,  # or name
    crm_stage_id=stage.id,
).run()

Question

Is there a cleaner or recommended pattern to parameterize the target CRM stage per automation? Examples welcome.

Thanks.

0
Avatar
Descartar
¿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
CRM change name automatically
crm automated
Avatar
Avatar
Avatar
Avatar
3
feb 24
2849
Automated action to create new scheduled activity Resuelto
crm automated
Avatar
Avatar
1
abr 23
9675
CRM automations Resuelto
crm automated odoo17
Avatar
Avatar
1
dic 24
1885
How to disable autofill in CRM Module when we select Customers?
crm automated v17
Avatar
Avatar
Avatar
2
mar 24
2729
Link opportunity to contact using automated action
action crm automated
Avatar
0
oct 21
2589
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