Odoo Help


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.


how to check a lead type is 'lead' or 'opportunity'?

on 5/26/14, 2:00 AM 619 views

Hello everyone,

here i want to check a lead type is 'lead' or 'opportunity' , and type is lead means send a mail,

here is my code,

    def _check_lead(self, cr, uid, ids, fields, args, context=None):
            for lead in self.browse(cr, uid, ids):

                if lead.type == 'lead':

                    sender = 'demo1@demo.com'
                    receivers = ['demo@demo.com']

                    message = """From: Administrator Test <administrator@demo.com>
                    To: To Person <demo@demo.com>
                    Subject: SMTP e-mail test

                    This is a test e-mail message.

                       smtpObj = smtplib.SMTP('mail.demo.com',25)
                       smtpObj.login("administrator@demo.com", "password")
                       smtpObj.sendmail(sender, receivers, message)         
                    except SMTPException:
                       raise osv.except_osv(('Your mail was not send, because the Server connection was problem.'))


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)


Asked: 5/26/14, 2:00 AM
Seen: 619 times
Last updated: 3/16/15, 8:10 AM