Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
13523 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Example,

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:
            try:
                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"/>
        </record>

Or

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

 

 

 

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi all ,

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

procedure?anyone? 

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 10 20
4243
1
thg 2 16
9603
0
thg 9 25
4
2
thg 8 25
413
1
thg 9 25
409