This method in custom model alert
here action have current object and mail depends on it.
def send_alert_mail(self, action):
for record in self:
alrt_mail=[]
if record.template_id:
mail_id = self.env['mail.template']
current_obj = action.values() #record.template_id is selected template obj.
values = mail_id.generate_email(record.template_id.id,current_obj[0])
for u in record.alrt_users_ids:
if u.email:
alrt_mail.append(u.res_usr_id.partner_id.id)
if alrt_mail:
values['partner_ids'] = [(6,0,[alrt_mail])]
values['email_from'] = record.act_user_id.login
mail_mail_obj = self.env['mail.message']
msg_id = mail_mail_obj.create(values)
return True
result = method(recs, *args, **kwargs)
File "/home/pchouksey1/workspace/dexciss/simple/simple_10/repo1010/alert_management/model/alert_management.py", line 350, in create
action._process(action._filter_post(record))
File "/home/pchouksey1/workspace/dexciss/simple/simple_10/repo1010/alert_management/model/alert_management.py", line 207, in _process
self.send_mail(records, action_done)
File "/home/pchouksey1/workspace/dexciss/simple/simple_10/repo1010/alert_management/model/alert_management.py", line 229, in send_mail
values = mail_id.generate_email(record.template_id.id,current_obj[0])
File "/home/pchouksey1/workspace/dexciss/simple/simple_10/core10/addons/mail/models/mail_template.py", line 496, in generate_email
if template.lang:
AttributeError: 'bool' object has no attribute 'lang'
how to resolve error or there is any solution for send mail using template in odoo10
Hope this will helps: http://learnopenerp.blogspot.com/2017/08/odoo-how-to-send-email-on-button-click.html