[IMP] mail, various: send email to assigned people
When a user is assigned to a model on a user_id field an email is sent to him containing a link to the document. This way the user is warned he is now responsible of the task / issue / lead / ...
This commit is contained in:
@@ -2004,10 +2004,17 @@ class MailThread(models.AbstractModel):
|
||||
"""
|
||||
if not partner_ids:
|
||||
return
|
||||
for record_id in self.ids:
|
||||
for record in self:
|
||||
record.message_post_with_view(
|
||||
'mail.message_user_assigned',
|
||||
composition_mode='mass_mail',
|
||||
partner_ids=[(4, pid) for pid in partner_ids],
|
||||
auto_delete=True,
|
||||
auto_delete_message=True,
|
||||
subtype_id=self.env.ref('mail.mt_note').id)
|
||||
messages = self.env['mail.message'].sudo().search([
|
||||
('model', '=', self._name),
|
||||
('res_id', '=', record_id),
|
||||
('res_id', '=', record.id),
|
||||
('subtype_id', '!=', False),
|
||||
('subtype_id.internal', '=', False)], limit=1)
|
||||
if messages:
|
||||
|
||||
@@ -38,5 +38,17 @@
|
||||
</p>
|
||||
</template>
|
||||
|
||||
<template id="message_user_assigned">
|
||||
<p>Dear <t t-esc="object.user_id.name"/>,</p>
|
||||
<p>You have been assigned to the <t t-esc="object._description.lower()"/> <t t-esc="object.name_get()[0][1]"/>.</p>
|
||||
<p>
|
||||
<a t-att-href="'/mail/view?model=%s&res_id=%s' % (object._name, object.id)"
|
||||
style="background-color: #9E588B; margin-top: 10px; padding: 10px; text-decoration: none; color: #fff; border-radius: 5px; font-size: 16px;">
|
||||
View <t t-esc="object._description.lower()"/>
|
||||
</a>
|
||||
</p>
|
||||
<p style="color:#9E588B;">Powered by <a href="https://www.odoo.com">Odoo</a>.</p>
|
||||
</template>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user