Odoo Help


How to send email and notification url?

on 5/22/13, 1:46 PM 3,203 views


I try to send a notification and e-mail to specified users, or groups, when i click a button. I've already gotten notifications work, but my e-mails are not sent, I do not know what I'm doing wrong. I've tried also send a URL for the user to directly access, but I can't get the browser URL, instead of leaving written manually.

This is my code.

# Send E-Mail
def enviar_email(self, cr, uid, user_ids, text=None, context=None):
    osv.logging.log(100, "[Alca] enviar_email:hr_expense:hr_expense_nervia")
    mail_compose = self.pool.get('mail.compose.message')

    for user in user_ids:
        compose_id = mail_compose.create(cr, user,
            {'subject': 'Asunto', 'body': 'Este es mi mensaje', 'partner_ids': user_ids},
            {'default_composition_mode': 'mass_mail', 'default_starred': True})
        mail_compose.send_mail(cr, user, [compose_id])

# Send Notification
def send_notificacion(self, cr, uid, ids, text=None, context=None):
    osv.logging.log(100, "[Alca] send_notificacion:hr_expense:hr_expense_nervia")

    if context == None:
        context = {}

    context.update({'default_starred': True})

    for record in self.browse(cr, uid, ids, context=context):
        notify_to = []
        notify_to = self._get_autorized_contables(cr, uid, context)

        text = text + (" <a href=''>Procesar</a>" % (record.id))

        self.enviar_email(cr, uid, notify_to, text, context)

        # Loguea una nota en la nota de gastos
        self.message_post(cr, uid, [record.id], _(text), context=context)
        # Suscribe a los usuarios y les manda una notificacion a la bandeja de entrada
        self.message_subscribe_users(cr, uid, [record.id], user_ids=notify_to, context=context)

I resolve the question about how to send email. :)

    from openerp import tools
    # Send E-Mail
    def enviar_email(self, cr, uid, user_ids, asunto = None, text=None, context=None):
            mUsr = self.pool.get("res.users")
            for usr in user_ids:
                user = mUsr.browse(cr, uid, usr)
                if user.email:
                    subject = "[OpenERP] Notificacion: "+str(asunto)
                    body = text
                    <a href="mailto:tools.email_send('noreply@openerp.com'">tools.email_send('noreply@openerp.com'</a>, [user.email, ], subject, body)
on 6/17/13, 8:03 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: 5/22/13, 1:46 PM
Seen: 3203 times
Last updated: 3/16/15, 8:10 AM