Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

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

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
attendancehr_employeeodooV12
2 Risposte
7788 Visualizzazioni
Avatar
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
Avatar
Abbandona
Avatar
Shringar Gupta
Autore Risposta migliore

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
Avatar
Abbandona
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

Avatar
Waleed Ali Mohsen
Risposta migliore

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
Avatar
Abbandona
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
Attendances module in Kiosk Mode without user logged - Odoo12
attendance odooV12
Avatar
Avatar
1
nov 23
5064
Attendance clock visible
attendance odooV12
Avatar
0
ago 22
2118
attendance prevent signing
attendance odooV12
Avatar
0
ago 22
1853
How to link Odoo module with attandence [odoo 12 CE]
attendance relation hr_employee
Avatar
Avatar
1
lug 19
4578
ERROR: object has no attribute
attendance inherit hr_employee attribute_error
Avatar
Avatar
1
lug 15
16490
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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