Good day,
I have a binary field that holds an xml file which i generate with etree.Element
batchfile = fields.Binary("XML Batch File", readonly=True)
So i want to attach this Binary file so that I email it, but how can I do this?
def send_claim_batch(self):
self.ensure_one()
ir_model_data = self.env['ir.model.data']
try:
template_id = ir_model_data._xmlid_lookup('iemr_medical_aid.iemr_claim_batch_email')[2]
except ValueError:
template_id = False
try:
compose_form_id = ir_model_data._xmlid_lookup('mail.email_compose_message_wizard_form')[2]
except ValueError:
compose_form_id = False
template_id = self.env.ref('event.event_registration_mail_template_badge')
compose_form = self.env.ref('mail.email_compose_message_wizard_form')
ctx = {
default_model: 'iemr.claim.batch',
default_res_id: self.ids[0],
default_use_template: bool(template_id),
default_template_id: template_id,
default_composition_mode: 'comment',
mark_so_as_sent: True,
force_email: True,
}
return {
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'mail.compose.message',
'views': [(compose_form.id, 'form')],
'view_id': compose_form.id,
'target': 'new',
'context': ctx,
}