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

V19: Create Scheduled Actions

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
2 Odpowiedzi
225 Widoki
Awatar
Benoit Vanasse

Hello and thank you for taking the time to review my post.

I would like to preface that I know a little about coding but not much, I am trying to configure my own Odoo for my small business.

I have to do maintenance on Equipment for my clients at set intervals (typically 3 month interval).

I would like to set Activity to remind myself to create the maintenance task. I do not wish to create the task automatically because those maintenance are often pushed to a later date by my customers.

With Studio, I added the following fields:

  • Date field : to display the next planned maintenance date
  • Integer field : to display the desired interval for maintenance (default 3)
I went to Scheduled Action and created a new action.
I set the Model to "Maintenance Equipment" which is where I keep my Equipment data.
The action is set to execute every 1 day.

I tried to get a code from GPT to run Action and create an automatic Activity everyday and then increase the value of the Date field by the number of months in the Integer field.

The code saves but when I try to run it manually, I do not see any added Activities being generated. Could anyone help me fix this code please?

Thank you!
Ben

Code:

# Get today's date using Odoo's fields helper
today = fields.Date.today()

# Find all equipment whose next PM date is today or earlier
to_process = records.filtered(
    lambda r: r.x_studio_next_pm_date and r.x_studio_next_pm_date <= today
)

for rec in to_process:
    # Create a reminder activity (admin must create PM task manually)
    env['mail.activity'].create({
        'res_model_id': env['ir.model']._get_id(rec._name),
        'res_id': rec.id,
        'activity_type_id': env.ref('mail.mail_activity_data_todo').id,
        'summary': "PM due for %s" % rec.name,
        'note': "Time to review this equipment and create a Field Service task if needed.",
        'date_deadline': today,
        'user_id': 11,  # put the correct user ID here
    })

    # Reschedule next PM date (use Odoo's Date.add, no import)
    freq = rec.x_studio_pm_frequency or 3
    next_date = fields.Date.add(rec.x_studio_next_pm_date, months=freq)

    # Use write() instead of direct assignment
    rec.write({
        'x_studio_next_pm_date': next_date,
    })


0
Awatar
Odrzuć
Codesphere Tech

Hello,
Try this:
to_process = model.search([
('x_studio_next_pm_date', '<=', today),
('x_studio_next_pm_date', '!=', False)
])

Benoit Vanasse
Autor
Thank you for the suggestion!

I read this updated code and still I did not get any activities generated. :(

Code:

# Get today's date using Odoo's fields helper
today = fields.Date.today()

# Find all equipment whose next PM date is today or earlier
to_process = model.search([
('x_studio_next_pm_date', '<=', today),
('x_studio_next_pm_date', '!=', False)
])

for rec in to_process:
    # Create a reminder activity (admin must create PM task manually)
    env['mail.activity'].create({
        'res_model_id': env['ir.model']._get_id(rec._name),
        'res_id': rec.id,
        'activity_type_id': env.ref('mail.mail_activity_data_todo').id,
        'summary': "PM due for %s" % rec.name,
        'note': "Time to review this equipment and create a Field Service task if needed.",
        'date_deadline': today,
        'user_id': 11,  # put the correct user ID here
    })

    # Reschedule next PM date (use Odoo's Date.add, no import)
    freq = rec.x_studio_pm_frequency or 3
    next_date = fields.Date.add(rec.x_studio_next_pm_date, months=freq)

    # Use write() instead of direct assignment
    rec.write({
        'x_studio_next_pm_date': next_date,
    })


Awatar
Kunjan Patel
Najlepsza odpowiedź
Hello Benoit Vanasse,
I hope you are doing well

Quick Fix for Odoo v19 Scheduled Actions
1. Search returns no records - verify equipment actually has x_studio_next_pm_date <= today
2.Missing required fields in activity creation - need res_model_id and user_id

Working Code:
  from datetime import date
  from dateutil.relativedelta import relativedelta

  today = date.today()
  equipment = env['maintenance.equipment'].search([
      ('x_studio_next_pm_date', '<=', today)
  ])
  for rec in equipment:
      env['mail.activity'].create({
          'res_model_id': env['ir.model']._get('maintenance.equipment').id,
          'res_id': env.user.id,
      })

      interval = rec.x_studio_pm_interval or 3
      rec.write({
          'x_studio_next_pm_date': today + relativedelta(months=interval)
      })

Debug: Check server logs after "Run Manually" to see if records are found.


I hope this information helps you

Thanks & Regards,
Kunjan Patel

0
Awatar
Odrzuć
Awatar
Cybrosys Techno Solutions Pvt.Ltd
Najlepsza odpowiedź
Hi,
To create a scheduled action in Odoo v19:

    First, activate Developer Mode.

    Then go to Settings → Technical → Automation → Scheduled Actions.

    Click New. Fill in:

        Name — give a clear title.

        Model — choose which model the action should run on (for example: sale.order, stock.move, or a custom model).

        Action — choose “code” if you want to run a Python method of the model, and in the Code field write something like:
        model.your_method_name()

        Interval — define how often it runs (e.g. every 1 day, 1 hour, etc).

        Next Execution Date, Number of Calls (e.g. -1 for infinite).

    Save the scheduled action — if “Active” is checked, Odoo will run it automatically according to schedule.

If you need to test it immediately, you can hit Run Manually from the Scheduled Actions list (in developer mode) to trigger it right away.


Hope it helps

-2
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ę
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