Odoo Help

Welcome!

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

0

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

By
Odoo
on 6/9/15, 3:21 AM 505 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....


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

1

Emipro Technologies Pvt. Ltd.

--Emipro Technologies Pvt. Ltd.--
Tiny ERP Pvt Ltd
http://www.odoo.com
5975
| 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

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.

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

Odoo
on 6/9/15, 9:30 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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