Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

Re-usable Server actions in Automation Rules

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
crmautomatedserver_actionsManufacturing OrderRules
450 Visualizzazioni
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
Abbandona
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
CRM change name automatically
crm automated
Avatar
Avatar
Avatar
Avatar
3
feb 24
2839
Automated action to create new scheduled activity Risolto
crm automated
Avatar
Avatar
1
apr 23
9647
CRM automations Risolto
crm automated odoo17
Avatar
Avatar
1
dic 24
1876
How to disable autofill in CRM Module when we select Customers?
crm automated v17
Avatar
Avatar
Avatar
2
mar 24
2724
Link opportunity to contact using automated action
action crm automated
Avatar
0
ott 21
2576
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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