<commit_before># -*- encoding: utf-8 -*-
##############################################################################
#
#    Copyright (C) 2016 Compassion CH (http://www.compassion.ch)
#    Releasing children from poverty in Jesus' name
#    @author: <NAME> <<EMAIL>>
#
#    The licence is in the file __openerp__.py
#
##############################################################################
from openerp import api, models, fields


class Email(models.Model):
    """ Add relation to communication configuration to track generated
    e-mails.
    """
    _inherit = 'mail.mail'

    ##########################################################################
    #                                 FIELDS                                 #
    ##########################################################################
    communication_config_id = fields.Many2one('partner.communication.config')

    @api.multi
    def send(self, raise_exception=False):
        """ Create communication for partner, if not already existing.
        """
        super(Email, self).send(raise_exception=raise_exception)
        comm_obj = self.env['partner.communication.job'].with_context(
            no_print=True, default_attachment_ids=False)
        config = self.env.ref(
            'partner_communication.default_communication')
        for email in self.filtered(lambda e: e.mail_message_id.model !=
                                   'partner.communication.job'):
            communication = comm_obj.search([('email_id', '=', email.id)])
            if not communication:
                for partner in email.recipient_ids:
                    comm_obj.create({
                        'config_id': config.id,
                        'partner_id': partner.id,
                        'user_id': self.env.uid,
                        'object_ids': email.recipient_ids.ids,
                        'state': 'done',<commit_msg>FIX bug in send e-mail inheritance<commit_after># -*- encoding: utf-8 -*-
##############################################################################
#
#    Copyright (C) 2016 Compassion CH (http://www.compassion.ch)
#    Releasing children from poverty in Jesus' name
#    @author: <NAME> <<EMAIL>>
#
#    The licence is in the file __openerp__.py
#
##############################################################################
from openerp import api, models, fields


class Email(models.Model):
    """ Add relation to communication configuration to track generated
    e-mails.
    """
    _inherit = 'mail.mail'

    ##########################################################################
    #                                 FIELDS                                 #
    ##########################################################################
    communication_config_id = fields.Many2one('partner.communication.config')

    @api.multi
    def send(self, auto_commit=False, raise_exception=False):
        """ Create communication for partner, if not already existing.
        """
        super(Email, self).send(
            auto_commit=auto_commit, raise_exception=raise_exception)
        comm_obj = self.env['partner.communication.job'].with_context(
            no_print=True, default_attachment_ids=False)
        config = self.env.ref(
            'partner_communication.default_communication')
        for email in self.exists().filtered(
                lambda e: e.mail_message_id.model !=
                'partner.communication.job'):
            communication = comm_obj.search([('email_id', '=', email.id)])
            if not communication:
                for partner in email.recipient_ids:
                    comm_obj.create({
                        'config_id': config.id,
                        'partner_id': partner.id,
                        'user_id': self.env.uid,
                        'object_ids': email.recipient_ids.ids,
                        'state': 'done',
{'fraction_non_alphanumeric': 0.24422442244224424, 'fraction_numerical': 0.0030464584920030465, 'mean_word_length': 2.3877901977644025, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1543023', 'n_tokens_mistral': 989, 'n_tokens_neox': 910, 'n_words': 202}