Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Diskusi
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Estate Management
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

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

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

V19: Create Scheduled Actions

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
2 Replies
224 Tampilan
Avatar
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
Avatar
Buang
Codesphere Tech

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

Benoit Vanasse
Penulis
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,
    })


Avatar
Kunjan Patel
Jawaban Terbai
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
Avatar
Buang
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Jawaban Terbai
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
Avatar
Buang
Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Tugas
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة 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 adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik Odoo.

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