This question has been flagged
1 Reply
7388 Views

hello everyone ! i'm trying to use the send_mail function of account.invoice. and need to know what does the function do, i mean i've seen the code and still don't get some parts, like action_invoice_sent()

ctx = dict(            
    default_model='account.invoice',
    default_res_id=self.id,            
    default_use_template=bool(template),            
    default_template_id=template.id,            
    default_composition_mode='comment',            
    mark_invoice_as_sent=True,        
)
 and then in send_mail()
@api.multi    
def send_mail(self):
    context = self._context
    if context.get('default_model') == 'account.invoice' and \
        context.get('default_res_id') and context.get('mark_invoice_as_sent'):
        invoice = self.env['account.invoice'].browse(context['default_res_id'])
        invoice = invoice.with_context(mail_post_autofollow=True)
        invoice.write({'sent': True})
        invoice.message_post(body=_("Invoice sent"))
    return super(mail_compose_message, self).send_mail()


Can anyone explain to me the process of sending an email in odoo till i can be able to use it ...

Avatar
Discard

Hope this will helps: https://goo.gl/z16PBZ

Best Answer

You can try:

template_id = self.env.ref('XML ID') # see Metadata on debug if you need it

template_id.send_mail(model_id, force_send=True)

Assuming you have your email template.


Avatar
Discard