Odoo Help


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

on 6/9/15, 3:21 AM 908 views

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....



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'),



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

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



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




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






  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"/>



Emipro Technologies Pvt. Ltd.

--Emipro Technologies Pvt. Ltd.--
| 6 7 8
Rajkot, India
--Emipro Technologies Pvt. Ltd.--

Being an emerging leader in IT market since 2011, Emipro Technologies Pvt. Ltd. has been providing a wide range of business solutions in Odoo & Magento. We are pleased to have a large pool of contented customers with our meticulous work in the domain of ERP & e-Commerce. A ray of relief & satisfaction to  our customers heart by our successful deployment in their organization, purely represents our success in Odoo platform. Hence, we take pride for being an Odoo partner with a vision of expanding our strategic alliances with our customers to offer them high value-added, trustworthy & cost effective solutions.


Since establishment, our business has span across 11 countries of the world. Our customers are companies of all sizes ranging from start-ups to large enterprises, who realize that they need a professional business solutions to generate revenue streams, establish proper communication channels or streamline business operations. Standing with strong determination of customer satisfaction, observing each minute detail of their business processes, providing proper guidance and moving forth to develop product accordingly adds our value and reliability among our customers. 


We are blessed with efficient, passionate & eclectic young developers who have come across almost all kinds of business profiles, working with full dedication, applying creativity & new features in existing modules and completing customer's projects successfully on predefined target. Our in-depth knowledge while giving business solutions in Odoo allows us to offer following services to our customers :


  • Consulting
  • Installation, Configuration & Customization
  • Training & Support
  • Maintenance
  • Upgradation
  • Documentation
  • Crafting community modules
  • Drafting videos on demand
  • Smart Apps development

We will be :) to welcome you @ www.emiprotechnologies.com to solve any kind of your business needs around Odoo. However we are just an inch away from you by email info@emiprotechnologies.com or a tweet to @EmiproTech

Emipro Technologies Pvt. Ltd.
On 6/9/15, 8:31 AM


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.

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

on 6/9/15, 9:30 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 6/9/15, 3:21 AM
Seen: 908 times
Last updated: 6/11/15, 12:32 AM