Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

My Custom Scheduler Functionality is not Running for a custom module Need a help

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
mailschedulerautomatic_email
1 Répondre
5273 Vues
Avatar
ABU K

I hr.employee ,create 3 date field for notification to employee to expire his document details.In my scheduler function call is invoked only three steps after that its not working any thing ,and functionality is stuck ,if I use a button for this action then mail alert is working perfectly.issue is in my scheduled action below is my code....


.py

-------------------------------------------------------------------------------------


class hr_employee(osv.osv):

_inherit = 'hr.employee'

_columns = {

  'passport_expiry':fields.date('Passport expiry'),

'visa_issue':fields.date('Visa issue Date'),

'visa_expiry':fields.date('Visa Expiry'),

'emirates_id_expiry':fields.date('Emirates ID Expiry'),

'join_date':fields.date('Join Date'),

'insurance_id_expiry':fields.date('Insurance Expiry'),

'departmnet_id':fields.many2one('hr.department','Department'),

'division':fields.many2one('hr.division','Division'),

'expiry_day_limit':fields.integer('Limit(Alert before/Days?)'),

'last_working_date_employee':fields.date('Last Working Date')

#'limit_days':fields.integer('Limint')

}

def send_expiry_email(self, cr, uid, ids=None, context=None):

print 'o'*200

  today = datetime.datetime.today()

today = datetime.datetime.strptime(datetime.datetime.strftime(today, DF), DF)

  print "DF -->> ", DF            #################DF -->> %Y-%m-%d  )after this line code is not excecuting.............

for partner in self.browse(cr, uid, ids, context=context):  #From Here Scheduler is not working

  passport_expiry_days = 0

visa_expiry_days=0

emirates_id_expiry_days=0

insuarance_id_expiry_days=0

if partner.passport_expiry:

passport_expiry = datetime.datetime.strptime(partner.passport_expiry, DF) - today

 

if int(passport_expiry.days) <= partner.expiry_day_limit:

passport_expiry_days = passport_expiry.days

  if partner.visa_expiry:

visa_expiry = datetime.datetime.strptime(partner.visa_expiry, DF) - today

  if int(visa_expiry.days) <= partner.expiry_day_limit:

visa_expiry_days = visa_expiry.days

  if partner.emirates_id_expiry:

emirates_id_expiry = datetime.datetime.strptime(partner.emirates_id_expiry, DF) - today

  if int(emirates_id_expiry.days) <= partner.expiry_day_limit:

emirates_id_expiry_days = emirates_id_expiry.days


if partner.insurance_id_expiry:

insuarance_id_expiry = datetime.datetime.strptime(partner.insurance_id_expiry, DF) - today


if int(insuarance_id_expiry.days) <= partner.expiry_day_limit:

insuarance_id_expiry_days = insuarance_id_expiry.days


partner_email=partner.work_email

passport_expiry=partner.passport_expiry

visa_expiry=partner.visa_expiry

emirates_expiry=partner.emirates_id_expiry

insurance_expiry=partner.insurance_id_expiry

  body = "Employee %s has Expired" %( partner.name)

footer="Please Update Your details"

if passport_expiry_days:

body = "%s passport on %s day," % (body,passport_expiry)

if visa_expiry_days:

body = "%s Visa %s on day," % (body,visa_expiry)

if emirates_id_expiry_days:

body = "%s Emirates %s on day," %( body,emirates_expiry)

if insuarance_id_expiry_days:

body = "%s Insurance %s on day," % (body,insurance_expiry)


mail_values= {

'body_html' :'<pre><span class="inner-pre" style="font-size: 15px">%s</br>%s</span></pre>' %(body,footer),

'record_name': 'dsdds',

'email_from': 'test@yahoo.in',

'email_to': partner_email,

'subject': 'Employee Expiry Details'

}

mail_id = self.pool.get('mail.mail').create(cr, uid, mail_values, context=context)

self.pool.get('mail.mail').send(cr, uid, [mail_id])

return True



.xml file

----------------------------------------------------------



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

<field name="name">Employee Document Expiry scheduler</field>

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

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

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

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

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

<field eval="'hr.employee'" name="model"/>

<field eval="'send_expiry_email'" name="function"/>

<field eval="'()'" name="args"/>

</record>

0
Avatar
Ignorer
Avatar
Emipro Technologies Pvt. Ltd.
Meilleure réponse

Hi,

When any method is calling from scheduler then you can not get any input inside "ids" argument. So, when ids=None then you have to set it before processing it as like below.

def send_expiry_email(self, cr, uid, ids=None, context=None):

print 'o'*200

today = datetime.datetime.today()

today = datetime.datetime.strptime(datetime.datetime.strftime(today, DF), DF)

print "DF -->> ", DF

if not ids:

    ids = self.search(cr, uid, []) #It will give you ids of all employee. But you can manage domain to get as you want.

for partner in self.browse(cr, uid, ids, context=context):

.......

....


I think you get an issue inside your code. I hope it will help you.

1
Avatar
Ignorer
ABU K
Auteur

Thanks Emiproo.......Works Perfectly..........I

Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Mail scheduler for Odoo event
mail scheduler event
Avatar
Avatar
1
sept. 23
3221
Scheduled action (Email Queue Manager) does not send automatically email from queue. Résolu
mail scheduler odooV8
Avatar
Avatar
Avatar
8
mai 23
26027
Safe to delete system notifications?
mail scheduler notifications
Avatar
Avatar
1
mars 15
6467
<( Servicio al pasajero)||¿Cómo hablar directamente en Volaris?
mail
Avatar
0
oct. 25
558
Emails to Microsoft Outlook/Hotmail are rejected
mail
Avatar
1
oct. 25
823
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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