Skip to Content
Odoo मेन्यू
  • Sign in
  • मुफ़्त में आज़माएं
  • ऐप्लिकेशन
    फ़ाइनेंस
    • अकाउंटिंग
    • इनवॉइसिंग
    • एक्सपेंस
    • स्प्रेडशीट (बीआई)
    • डॉक्यूमेंट्स
    • साइन
    सेल्स
    • सीआरएम
    • सेल्स
    • पीओएस शॉप
    • पीओएस रेस्टोरेंट
    • सब्सक्रिप्शन
    • रेंटल
    वेबसाइट
    • वेबसाइट बिल्डर
    • ई-कॉमर्स
    • ब्लॉग
    • फ़ोरम
    • लाइव चैट
    • ई-लर्निंग
    सप्लाई चेन
    • इन्वेंट्री
    • मैन्युफ़ैक्चरिंग
    • पीएलएम
    • परचेज़
    • मेंटेनेंस
    • क्वालिटी
    मानव संसाधन
    • कर्मचारी
    • रिक्रूटमेंट
    • टाइम ऑफ़
    • अप्रेज़ल
    • रेफ़रल
    • फ़्लीट
    मार्केटिंग
    • सोशल मार्केटिंग
    • ईमेल मार्केटिंग
    • एसएमएस मार्केटिंग
    • इवेंट
    • मार्केटिंग ऑटोमेशन
    • सर्वे
    सेवाएं
    • प्रोजेक्ट
    • टाइमशीट
    • फ़ील्ड सर्विस
    • हेल्पडेस्क
    • प्लानिंग
    • अपॉइंटमेंट
    प्रॉडक्टिविटी
    • डिस्कस
    • अप्रूवल
    • आईओटी
    • वीओआईपी
    • नॉलेज
    • WhatsApp
    तीसरे पक्ष के ऐप्लिकेशन Odoo स्टूडियो Odoo क्लाउड प्लेटफ़ॉर्म
  • इंडस्ट्री
    रीटेल
    • बुक स्टोर
    • क्लोदिंग स्टोर
    • फ़र्नीचर स्टोर
    • ग्रॉसरी स्टोर
    • हार्डवेयर स्टोर
    • टॉय स्टोर
    Food & Hospitality
    • बार और पब
    • रेस्टोरेंट
    • फ़ास्ट फ़ूड
    • Guest House
    • बेवरिज डिस्ट्रीब्यूटर
    • होटल
    रियल एस्टेट
    • Real Estate Agency
    • आर्किटेक्चर फ़र्म
    • कंसट्रक्शन
    • एस्टेट मैनेजमेंट
    • गार्ड्निंग
    • प्रॉपर्टी ओनर असोसिएशन
    कंसल्टिंग
    • अकाउंटिंग फ़र्म
    • Odoo पार्टनर
    • मार्केटिंग एजेंसी
    • लॉ फ़र्म
    • टैलेंट ऐक्विज़िशन
    • ऑडिट & सर्टिफ़िकेशन
    मैन्युफ़ैक्चरिंग
    • टेक्सटाइल
    • Metal
    • फ़र्नीचर
    • फ़ूड
    • Brewery
    • कॉर्पोरेट गिफ़्ट
    हेल्थ & फिटनेस
    • स्पोर्ट्स क्लब
    • आईवियर स्टोर
    • फिटनेस सेंटर
    • वेलनेस प्रैक्टिशनर
    • फॉर्मेसी
    • हेयर सैलून
    Trades
    • Handyman
    • आईटी हॉर्डवेयर और सपोर्ट
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    अन्य
    • Nonprofit Organization
    • एन्वायरमेंटल एजेंसी
    • बिलबोर्ड रेंटल
    • फ़ोटोग्राफी
    • बाइक लीजिंग
    • सॉफ़्टवेयर रीसेलर
    Browse all Industries
  • कम्यूनिटी
    सीखें
    • ट्यूटोरियल्स
    • दस्तावेज़
    • सर्टिफ़िकेशन
    • ट्रेनिंग
    • ब्लॉग
    • पॉडकास्ट
    शिक्षा को बढ़ावा दें
    • एजुकेशन प्रोग्राम
    • स्केल अप! बिजनेस गेम
    • Odoo के ऑफ़िस में आएं
    सॉफ़्टवेयर पाएं
    • डाउनलोड
    • वर्शन की तुलना करें
    • रिलीज़
    साथ मिलकर काम करें
    • Github
    • फ़ोरम
    • इवेंट
    • अनुवाद
    • पार्टनर बनें
    • Services for Partners
    • अपना अकाउंटिंग फ़र्म रजिस्टर करें
    सेवाएं पाएं
    • पार्टनर ढूंढें
    • अकाउंटेंट खोजें
    • सलाहकार की मदद लें
    • इम्प्लिमेंटेशन सेवाएं
    • कस्टमर रेफ़रेंस
    • सहायता
    • अपग्रेड
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    डेमो देखें
  • कीमत
  • सहायता

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

  • सीआरएम
  • e-Commerce
  • लेखांकन
  • इन्वेंटरी
  • PoS
  • प्रोजेक्ट
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
Help

Cron job does not execute python code on scheduler, only on Run Manually button.

Subscribe

Get notified when there's activity on this post

This question has been flagged
croncronjob
3 Replies
12879 Views
Avatar
Gagea Alexandru

Hello,


The bellow code inserts data from another database into postgres table product.public.category. 

My goal is to run this on a scheduler. I've configured a cron job to run every hour for this method.


The cron job executes python code: model.get_grupe() . The issues here is that the code does not get executed on the cron instead if i click on Run Manually button from the cron, it will work.

What can I do to make it work on the scheduler ? 


Odoo 13 CE.


def get_grupe(self):

        lst = self.get_from_borg('GrupeProduse')

        grupe = self.env['product.public.category'].search([])

        for item in lst:

            it = item.split('\t')

            if it[0].isdigit():

                id_cat = it[0]

                name_categ = it[1].title()

                type = it[2]

                id_ramura = it[3]

                name_ramura = it[4].title()

                parent_id = False

                ramura = grupe.search(

                    [('parent_id', '=', False), ('id2', '=', id_ramura)])

                if ramura:

                    parent_id = ramura[0].id

                    ramura[0].name = name_ramura

                else:

                    ramura = self.env['product.public.category'].create({

                        'id2': id_ramura,

                        'name': name_ramura,

                        'parent_id': False

                    })

                    parent_id = ramura.id

                grupa = grupe.search([('parent_id',  '!=', False) ,('id2', '=', id_cat)])

                if grupa:

                    grupa[0].write({

                        'name': name_categ,

                        'parent_id': parent_id

                    })

                else:

                    self.env['product.public.category'].create({

                        'id2': id_cat,

                        'name': name_categ,

                        'parent_id': parent_id

                    })


Thank you.

1
Avatar
Discard
Jainesh Shah(Aktiv Software)

Can you please add your scheduler code.

Gagea Alexandru
Author

<record id="sync_categories" model="ir.cron">

<field name="interval_type">hours</field>

<field name="interval_number">2</field>

<field name="name">Sync categories</field>

<field name="user_id" ref="base.user_root"/>

<field name="numbercall">-1</field>

<field name="priority">5</field>

<field name="doall">False</field>

<field name="active">False</field>

<field name="interval_number">1</field>

<field name="model_id" ref="model_borg_client"/>

<field name="state">code</field>

<field name="code">model.get_grupe()</field>

</record>

Avatar
Gagea Alexandru
Author Best Answer

Issue solved, the problem was because of the translations. I was updating only the category name  in the product categories table and I  had to update the translation for the category as well in the ir.translation table.

0
Avatar
Discard
Mahmoud

i have the same problem but what you say is not the solution :(

Avatar
Adil Akbar
Best Answer

Hi, you can follow this link for this:

https://youtu.be/iBvtwy8x_E0

Hope it helps,

Thanks

0
Avatar
Discard
Avatar
Prakash
Best Answer


Check Preference --> Timezone  = Current user timezone.

If other timezone may be delay to auto execute.

or you can debug code adding _logger in your cron job method.

import logging
_logger = logging.getLogger(__name__)

_logger.warning('Cron Job testing')


0
Avatar
Discard
Gagea Alexandru
Author

The job executes when it should. So, my code updates data in product_public_category table. I've deleted all records in the table and now the table gets populated at the right time, every time without deleting the data in the table anymore. However I cannot delete the data in the production database just to make the scheduler work. I need to find another solution.

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
Using CRON job to download and attach pdf to binary field ODOO16
cron cronjob ODOO16
Avatar
0
अक्तू॰ 24
3125
Cron getting timeout
cron timeout cronjob
Avatar
Avatar
1
अग॰ 24
6177
How can i run a single auto scheduler in Odoo for multiple users at the same time?
cron scheduler cronjob
Avatar
0
मई 21
4624
Cron Job issue
cron nginx cronjob AttributeError
Avatar
Avatar
Avatar
Avatar
3
सित॰ 25
4158
Cron job showing error: RuntimeError: OrderedDict mutated during iteration
cron bug cronjob v14
Avatar
Avatar
1
मई 24
8505
कम्यूनिटी
  • ट्यूटोरियल्स
  • दस्तावेज़
  • फ़ोरम
ओपन सोर्स
  • डाउनलोड
  • Github
  • रनबॉट
  • अनुवाद
सेवाएं
  • Odoo.sh Hosting
  • सहायता
  • अपग्रेड
  • कस्टम डेवलपमेंट्स
  • शिक्षा
  • अकाउंटेंट खोजें
  • पार्टनर ढूंढें
  • पार्टनर बनें
हमारे बारे में
  • हमारी कंपनी
  • ब्रांड ऐसेट
  • संपर्क करें
  • नौकरियां
  • इवेंट
  • पॉडकास्ट
  • ब्लॉग
  • ग्राहक
  • लीगल • गोपनीयता
  • सुरक्षा
الْعَرَبيّة 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, बिज़नेस से जुड़े ऐप्लिकेशन का एक कलेक्शन है जो ओपन सोर्स पर आधारित है. इसमें आपकी कंपनी की हर ज़रूरत के लिए ऐप्लिकेशन हैं. जैसे, सीआरएम, ई-कॉमर्स, अकाउंटिंग, इन्वेंट्री, पॉइंट ऑफ़ सेल, प्रोजेक्ट मैनेजमेंट वगैरह.

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