Created
June 14, 2017 22:39
-
-
Save dperaltab/2cd1c6edc847389c47018499982e4f0b to your computer and use it in GitHub Desktop.
Ejemplo básico para enviar una notificación y email a un usuario determinado. (Odoo)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Class: MsAdjudicacionPlaza | |
# Registro de la adjudicación de las plazas. | |
class MsAdjudicacionPlaza(models.Model): | |
name = 'ms.adjudicacion.plaza' | |
_inherit = ['mail.thread', 'ir.needaction_mixin'] | |
_description = u"Adjudicación plaza" | |
# ... | |
# Envia una notificación y correo al usuario | |
def enviar_invitacion(self): | |
post_kwargs = { | |
'author_id': self.env.user.partner_id.id, | |
'email_from': self.env.user.partner_id.email, | |
'partner_ids': [self.profesional_id.partner_id.id] | |
} | |
template = self.env.ref('minsa_serums.email_template_invication_permuta')\ | |
.get_email_template(self.id) | |
body_html = self.env['mail.template'].with_context(template._context)\ | |
.render_template(template.body_html, 'ms.adjudicacion.plaza', self.id) | |
self.message_post( | |
body=body_html, | |
subject="Invitación para permutar plaza", | |
message_type='comment', | |
subtype='mt_comment', | |
**post_kwargs | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<odoo> | |
<data noupdate="0"> | |
<record id="email_template_invication_permuta" model="mail.template"> | |
<field name="name">Invitación permuta</field> | |
<field name="model_id" ref="minsa_serums.model_ms_adjudicacion_plaza"/> | |
<field name="lang">${object.user_id.lang}</field> | |
<field name="subject">Invitación para permutar plaza</field> | |
<field name="body_html"><![CDATA[ | |
<p> | |
<strong>Invitación para permutar plaza ${object.institucion_id.name}</strong> | |
</p> | |
<p>MINSA</p> | |
]]></field> | |
</record> | |
</data> | |
</odoo> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment