Odoo Help


Automated Action Birthday Email

Sohail Abbasi
on 6/27/14, 11:14 AM 3,907 views

Can anyone guide me how to auto send a birthday email for every customer on his/her birthday. My idea is to use a scheduler which checks if today is someone's birthdate and sends an email. I am a novice in this and detailed help would be much appreciated....



| 5 4 7
Bikaner, India

OpenERP Devloper at SunARC Technology

On 7/4/14, 6:06 AM

You can create scheduler and in the method search the record with the domin condition dob is equal to current date month and day. If record find then send mail using mai.mail object.


To create the method in custom module:-

from openerp.osv import fields,osv
import datetime

class res_partner(osv.osv):
    _inherit = 'res.partner'

def send_birthday_email(self, cr, uid, ids=None, context=None):
        partner_obj = self.pool.get('res.partner')
        mail_mail = self.pool.get('mail.mail')
        mail_ids = []
        today = datetime.datetime.now()    
        today_month_day = '%-' + today.strftime('%m') + '-' + today.strftime('%d')    
        par_id = partner_obj.search(cr, uid, [ ('customer','=',True),('birthdate','like',today_month_day)])
        if par_id:
                for val in partner_obj.browse(cr, uid, par_id):
                    email_from = val.email
                    name = val.name                
                    subject = "Birthday Wishes"
                    body = _("Hello %s,\n" %(name))                 
                    body += _("\tWish you Happy Birthday\n")                     
                    footer = _("Kind regards.\n")         
                    footer += _("%s\n\n"%val.company_id.name)
                    mail_ids.append(mail_mail.create(cr, uid, {
                        'email_to': email_from,
                        'subject': subject,
                        'body_html': '<pre><span class="inner-pre" style="font-size: 15px">%s<br>%s</span></pre>' %(body, footer)
                     }, context=context))
                    mail_mail.send(cr, uid, mail_ids, context=context)            
            except Exception, e:
                print "Exception", e    
        return None

In the xml File Create Scheduler

 <record forcecreate="True" id="ir_cron_employee_birth" model="ir.cron">
            <field name="name">Employee Birthday scheduler</field>
            <field eval="True" name="active"/>            
            <field name="interval_number">1</field>
            <field name="interval_type">days</field>
            <field name="numbercall">-1</field>
            <field eval="False" name="doall"/>
            <field eval="'res.partner'" name="model"/>
            <field eval="'send_birthday_email'" name="function"/>
            <field eval="'()'" name="args"/>


In Openerp using Menu Setting - > Configuration -> Scheduler -> Scheduler Action Create scheduler.






| 4 3 8
Delhi, India

Nothing to say .... :)

On 6/27/14, 11:28 PM

Just create a scheduler to check dob of customers if date is today create an email. you do not need to send email. there is other scheduler to send email. It will send created email automatically at scheduled interval of time but if you want you can send email too by same scheduler like you said. All depends on you, do it how you want. Let me know if any help is needed.

On 12/19/14, 6:40 AM

Hi all ,

I have similar type of tasks to do . i want to send auto E-mail to all customers after a week?


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

4 follower(s)


Asked: 6/27/14, 11:14 AM
Seen: 3907 times
Last updated: 5/24/16, 7:18 AM