Once done schedule activity then I will click " Mark as done" button to trigger email to who created schedule activity Please help me ?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
from odoo import api, fields, models, _
class MailActivity(models.Model):
_inherit = "mail.activity"
def action_feedback(self, feedback=False):
message = self.env['mail.message']
for rec in self.filtered(lambda m: m.res_model in ['sale.order', 'account.invoice', 'purchase.order', 'tac.purchase.shipment', 'sale.agreement','helpdesk.ticket']):
# Check Activity Create and Assigned User
if self.create_user_id != self.user_id and self.create_user_id.id not in (1, 2) and self.user_id.id not in (1, 2):
# Send Email For Sale Order
if self.res_model == 'sale.order':
server_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url', default='http://yourdomain.com')
form_view = self.env.ref('sale.view_order_form')
server_url = server_url + "/web?#id=%s&action_id=%s&model=%s" % (
self.res_id, form_view.id, self.res_model)
obj = self.env['sale.order'].browse(self.res_id)
if self.create_user_id.login:
mail_template = self.env.ref('tac_activity_notification.tac_email_template_mail_activity_done')
if mail_template:
mail_template.with_context(feedback=feedback, server_url=server_url, obj=obj.name).send_mail(self.id, force_send=True, email_values={'email_to': self.create_user_id.login})
if feedback:
self.write(dict(feedback=feedback))
for activity in self:
record = self.env[activity.res_model].browse(activity.res_id)
record.message_post_with_view(
'mail.message_activity_done',
values={'activity': activity},
subtype_id=self.env['ir.model.data'].xmlid_to_res_id('mail.mt_activities'),
mail_activity_type_id=activity.activity_type_id.id,
)
message |= record.message_ids[0]
self.unlink()
return message.ids and message.ids[0] or False
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up