Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

[help] Write field 'nextcall' in ir.cron for Schedule Action, get Timezone user in xml file,

Odoberať

Get notified when there's activity on this post

This question has been flagged
timezoneir.cron
4 Replies
18819 Zobrazenia
Avatar
Minh Nguyen

Hi, I am learning to write a schedule action and i have a problem at field 'nextcall', Here is my code:

<record id="cron_do_task" forcecreate='True' model="ir.cron">

<field name="name">Check Bed</field>

<field eval="True" name="active"/>

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

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

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

<field name="nextcall" eval="datetime.now(pytz.timezone('UTC')).strftime('%Y-%m-%d 23:59:59')" />

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

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

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

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

</record>

This code is right, but nextcall return Time in UTC. I want nextcall to be time with my timezone ('Asia/Ho_Chi_Minh'), so i tried:  datetime.now(pytz.timezone(self._context.get('tz') or 'UTC')).strftime('%Y-%m-%d 23:59:59'), but i got error because xml can't define 'self'. How can i get timezone's user in xml file? Please suggest me some solutions.

Thanks and Regards,

Minh

1
Avatar
Zrušiť
Avatar
Buddy Lich
Best Answer

Could you try this code?

<field name="nextcall" eval="datetime.now() + (datetime.now(pytz.timezone('Aisa/Ho_Chi_Minh')).replace(hour=23, minute=59, second=59) - datetime.now(pytz.timezone('Aisa/Ho_Chi_Minh'))) % timedelta(hours=24)"/>

2
Avatar
Zrušiť
Tri Nanda

I tested this on Odoo14, and it working correctly,

Thank you,
Tri

fudo

Worked for me in odoo 15, but you should replace 'Asia/Ho_Chi_Minh' with 'Aisa/Ho_Chi_Minh' or else it will be error. This is a spelling issue.

fudo

With this answer, can i make it to nextcall will be come 2nd day after today? i've tried datetime.now() + datetime.now() but not working.

Avatar
Cuu Nguyen
Best Answer

I think u can try manual minus hour for 7, smt like this:

<field name="nextcall" eval="datetime.now(pytz.timezone('UTC')).strftime('%Y-%m-%d 16:59:59')" />
Hope that help!

0
Avatar
Zrušiť
Minh Nguyen
Autor

Hi Cuu Nguyen, I think that only good for gmt+7 , if we change timezone user, it willnot be ok and cant slove my issue.

Cuu Nguyen

Well, in that case I think u can use function to (re)set "nextcall" field after stored ur cron record. For example:

<function name="method_to_call" model="model_contains_method"/>

and ur method is smt like this:

def method_to_call(self):

ir_record = self.env.ref("module_name.cron_do_task")

ir_record.nexcall = <next time that u want it to be call - computed by yourself>

with cron_do_task is xml id of ur record and module_name is, well, I think u knew it :)

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

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
Time zone problem in python
timezone
Avatar
Avatar
2
apr 23
4224
How to change the time Zone in openerp?
timezone
Avatar
Avatar
Avatar
2
feb 21
17295
Time in Scheduled Action not matching time based on User Preferences Timezone
timezone
Avatar
1
okt 20
4295
Error on TimeZone Field Solved
timezone
Avatar
Avatar
Avatar
2
aug 19
4655
Is the javascript code in Odoo project which convert the localtime into UTC and vice versa? (Ver 9)
timezone
Avatar
0
sep 16
5282
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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