I have a kept a binary field for attachment file. If I click on the confirm button, mail should be send along with attachment file.
I have tried this code,
class Test(models.Model)
_name = 'test'
soft_copy = fields.Binary(string="Soft Copy")
file_name = fields.Char(string="File Name")
def action_confirm(self):
self.ensure_one()
self.state = 'confirm'
email_template = self.env.ref('module1.test_email_template')
email_template.send_mail(self.id, raise_exception=False, force_send=True)
Email Template,
<record id="test_email_template" model="mail.template">
<field name="name">Test</field>
<field name="subject">Checking Test</field>
<field name="email_from">xyz@gmail.com</field>
<field name="email_to">$employee_id.work_mail}</field>
<field name="model_id" ref="module1.model_test"/>
<field name="report_template" ref="module1.test_reports"/>
<field name="report_name">Test</field>
<field name="auto_delete" eval="True"/>
<field name="body_html"><![CDATA[ -----Content---
]]></field>
https://apps.odoo.com/apps/modules/12.0/send_an_email_with_pdf_attachmentv/