2018-01-16 06:58:15 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2018-01-16 11:34:37 +01:00
|
|
|
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
|
2018-01-16 06:58:15 +01:00
|
|
|
|
2018-01-16 11:34:37 +01:00
|
|
|
from flectra import api, fields, models, _
|
2018-01-16 06:58:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
class MailComposer(models.TransientModel):
|
|
|
|
_inherit = 'mail.compose.message'
|
|
|
|
|
|
|
|
@api.multi
|
|
|
|
def send_mail(self, auto_commit=False):
|
|
|
|
""" Method overriden to mark ISR as sent once a mail containing
|
|
|
|
it in attachment has been sent.
|
|
|
|
"""
|
|
|
|
context = self._context
|
|
|
|
if context.get('default_model') == 'account.invoice' and \
|
|
|
|
context.get('default_res_id') and \
|
|
|
|
context.get('l10n_ch_mark_isr_as_sent', False):
|
|
|
|
|
|
|
|
invoice = self.env['account.invoice'].browse(context['default_res_id'])
|
|
|
|
invoice = invoice.with_context(mail_post_autofollow=True)
|
|
|
|
invoice.l10n_ch_isr_sent = True
|
|
|
|
invoice.message_post(body=_("ISR sent"))
|
|
|
|
|
2018-04-05 10:25:40 +02:00
|
|
|
return super(MailComposer, self).send_mail(auto_commit=auto_commit)
|