Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Cron job not working in Odoo 15

Subscribe

Get notified when there's activity on this post

This question has been flagged
v15
3 Replies
8183 Views
Avatar
MercTrans

I tried to create a cron job in Odoo 15 and it is not working at all even though the terminal returns that the cron job was executed. 


I used this in my "automation.xml" file: 

noupdate="0">
id="ir_cron_scheduler_sync_status_action" model="ir.cron">
name="name">Auto Sync Payment Status
name="model_id" ref="model_model_name"/>
name="state">code
name="code">model.test_cron()
name="user_id" ref="base.user_root"/>
name="interval_number">1
name="interval_type">minutes
name="numbercall">-1

And my function is as simple as this:

@api.model
def test_cron(self):
print("test cron")


But when I run this scheduled action manually or I just let the server executes it, nothing is printed in the terminal. What might be the issue here? Please help!


0
Avatar
Discard
Avatar
shubham shiroya
Best Answer

Here are some possible solutions to troubleshoot the issue:

  1. Check Cron Configuration: Ensure that your cron job is properly configured in the automation.xml file. Double-check the correctness of the element structure and attributes, such as name, model_id, state, code, user_id, interval_number, and interval_type.log files are located in the Odoo installation directory. Look for any relevant entries that may provide insights into the issue.

  2. Enable Developer Mode: Enable the developer mode in Odoo to see detailed error messages. You can enable it by adding ?debug at the end of the URL or by activating the developer mode through the user interface (by going to "Settings" -> "Activate the Developer Mode").

  3. Restart Odoo Service: Restart the Odoo service to ensure that any changes made to the cron job or module are properly applied. Sometimes, changes may not take effect until the service is restarted.

  4. Verify Access Rights: Ensure that the user specified in the user_id attribute of the cron job has the necessary access rights to execute the job. The user should have appropriate permissions on the model and its associated methods.

  5. Check Server Timezone: Make sure the server's timezone is correctly set. Cron jobs in Odoo are executed based on the server's timezone configuration. Verify that the timezone is set correctly in the Odoo configuration file (odoo.conf).


0
Avatar
Discard
Avatar
Christopher DATO
Best Answer

Sorry for the late response,
The print() function won't display anything in odoo log file.
You should use a logging function to display infos in odoo log.

See example below:

import logging
_logger=logging.getLogger(__name__) 
_logger.info("MY FIRST INFO LOG")

I hope I've helped you...

0
Avatar
Discard
Avatar
Best Answer

Hello,

For the XML code:

 


For the python code:

@api.model
def test_cron(self):
print("test cron")

Be sure that the xmlfile is imported in the _manifest.py and the python file is imported in the __init_.py file.

For the model_id in the xml file:

You have to set model.model_name where the model is the name of your application and model_name is the name of your model where the function test_cron is declared.


Best regards,

Imal-Tech
 
Imal-Tech team




0
Avatar
Discard
MercTrans
Author

The problem is I already added the xml file and python file to manifest and init. The cron job actually runs but it doesn't execute the function.

MercTrans
Author

odoo_web | 2022-10-23 04:03:17,213 43 INFO merctrans odoo.addons.base.models.ir_cron: Starting job `Auto Sync Payment Status`.
odoo_web | 2022-10-23 04:03:17,215 43 INFO merctrans odoo.addons.base.models.ir_cron: Job `Auto Sync Payment Status` done.
odoo_web | 2022-10-23 04:04:20,286 43 INFO merctrans odoo.addons.base.models.ir_cron: Starting job `Auto Sync Payment Status`.
odoo_web | 2022-10-23 04:04:20,287 43 INFO merctrans odoo.addons.base.models.ir_cron: Job `Auto Sync Payment Status` done.
odoo_web | 2022-10-23 04:05:23,444 43 INFO merctrans odoo.addons.base.models.ir_cron: Starting job `Auto Sync Payment Status`.
odoo_web | 2022-10-23 04:05:23,451 43 INFO merctrans odoo.addons.base.models.ir_cron: Job `Auto Sync Payment Status` done.
odoo_web | 2022-10-23 04:06:26,610 43 INFO merctrans odoo.addons.base.models.ir_cron: Starting job `Auto Sync Payment Status`.
odoo_web | 2022-10-23 04:06:26,617 43 INFO merctrans odoo.addons.base.models.ir_cron: Job `Auto Sync Payment Status` done.
odoo_web | 2022-10-23 04:06:32,467 44 INFO merctrans odoo.addons.base.models.ir_cron: Starting job `Auto Sync Payment Status`.
odoo_web | 2022-10-23 04:06:32,481 44 INFO merctrans odoo.addons.base.models.ir_cron: Job `Auto Sync Payment Status` done.

You can see here that the cron job runs, but doesn't print anything to terminal

Jakub Sedinar

Hi, did you manage to fix it? or do you need help?

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
Prevent navigation if records are not save
v15
Avatar
Avatar
Avatar
2
Oct 25
3502
Creating user creates duplicated partner_id
v15
Avatar
Avatar
1
Sep 25
3369
Sales order line comment to Purchase order line comment Solved
v15
Avatar
Avatar
3
Jul 25
4570
attribute is not applied when dynamically rendering
v15
Avatar
1
May 25
2713
Odoo Custome Module Language Creation
v15
Avatar
Avatar
Avatar
Avatar
4
May 25
4149
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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