Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

Can I create one cron job and perform two actions through that ?

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
attendancehr_employeeodooV12
2 Răspunsuri
7780 Vizualizări
Imagine profil
Shringar Gupta

I want to create a cron job that will customize attendance module such that the employees who forgot to check out will be checked out automatically at a particular time and at the same time an email would be sent stating "you forgot to checkout, we have checked you out".

I have already created a cron job with auto checkout functionality, that is working perfectly fine. Now I want to send an email as well to those employees.

Here is my code.

```python

class hr_attendance(models.Model):
    _inherit = 'hr.attendance'

    def check_for_incomplete_attendances(self):

        not_checkout = self.env['hr.attendance'].search([('check_out', '=', False)]) 

        for rec in not_checkout:

            date_time = (datetime.now() + timedelta(days=0)).strftime('%Y-%m-%d 18:29:59') 

            rec.check_out = date_time

```

```xml

<odoo>

 <data noupdate = "1">

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

   <field name="name">Auto Checkout</field> 

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

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

   <field name="nextcall" eval="(DateTime.now() + timedelta(days=0)).strftime('%Y-%m-%d 18:29:59')"/>

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

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

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

   <field name="model_id" ref="hr_attendance.model_hr_attendance"/>

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

   <field name="code">

    model.check_for_incomplete_attendances()

    </field>

  </record>

 </data>

</odoo>

0
Imagine profil
Abandonează
Imagine profil
Shringar Gupta
Autor Cel mai bun răspuns

hello Waseem ,

Thankyou for the reply, I am unable to comment on your answer, due to less karma. I wanted to know can I create an xml email template and use it through python code. 

I have created a template, Don't know how to include it in python code.

Here is my template.

```xml

<odoo>

 <data noupdate ="1">

  <record id="email_template" model="mail.template">

   <field name="name">Attendance Reminder Email</field>

   <field name="model_id" ref="hr.model_hr_employee"/>

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

   <field name="email_from">${(object.company_id.email}</field>

   <field name="email_to">${object.work_email}</field>

   <field name="subject">Attendance Reminder ${object.name}</field>

   <field name="body_html">

    <![CDATA[

    Hello ${object.name},<br/>

     This is reminder that you didn't sign out today.<br/>

     Best regards...<br/>]]>

   </field>

  </record>

 </data>

</odoo>

```

0
Imagine profil
Abandonează
Waleed Ali Mohsen

Please refer to the below thread for how to call email template:

https://www.odoo.com/fr_FR/forum/aide-1/question/how-to-send-mail-using-template-in-odoo10-124844

Imagine profil
Waleed Ali Mohsen
Cel mai bun răspuns

The first thing that you need to add mail dependency in your manifest file. 

'depends': ['mail'],

and add mail.thread to _inherit as below:

_inherit = ['mail.thread']

and add the below code to check_for_incomplete_attendances method:

template_obj = self.env['mail.mail']
template_data = {
'subject': 'Due Invoice Notification : ' + current_date,
'body_html': message_body,
'email_from': sender,
'email_to': ", ".join(recipients)
}
template_id = template_obj.create(template_data)
template_obj.send(template_id)

In above code, you will create mail template by code and then fill all required data like subject,body_html,...etc.

0
Imagine profil
Abandonează
Enjoying the discussion? Don't just read, join in!

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

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
Attendances module in Kiosk Mode without user logged - Odoo12
attendance odooV12
Imagine profil
Imagine profil
1
nov. 23
5057
Attendance clock visible
attendance odooV12
Imagine profil
0
aug. 22
2118
attendance prevent signing
attendance odooV12
Imagine profil
0
aug. 22
1853
How to link Odoo module with attandence [odoo 12 CE]
attendance relation hr_employee
Imagine profil
Imagine profil
1
iul. 19
4563
ERROR: object has no attribute
attendance inherit hr_employee attribute_error
Imagine profil
Imagine profil
1
iul. 15
16486
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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