Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

Re-usable Server actions in Automation Rules

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
crmautomatedserver_actionsManufacturing OrderRules
457 Widoki
Awatar
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
Awatar
Odrzuć
Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
CRM change name automatically
crm automated
Awatar
Awatar
Awatar
Awatar
3
lut 24
2841
Automated action to create new scheduled activity Rozwiązane
crm automated
Awatar
Awatar
1
kwi 23
9651
CRM automations Rozwiązane
crm automated odoo17
Awatar
Awatar
1
gru 24
1877
How to disable autofill in CRM Module when we select Customers?
crm automated v17
Awatar
Awatar
Awatar
2
mar 24
2725
Link opportunity to contact using automated action
action crm automated
Awatar
0
paź 21
2578
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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