[FIX] mail generation

This commit is contained in:
unknown
2013-06-06 17:26:52 +02:00
parent f20bf46aba
commit 17308585e4
4 changed files with 34 additions and 3 deletions

View File

@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import mail
from . import run
from . import line
from . import account

View File

@@ -75,7 +75,7 @@ class CreditControlLine(orm.Model):
'partner_id': fields.many2one('res.partner', "Partner", required=True),
'amount_due': fields.float('Due Amount Tax incl.', required=True, readonly=True),
'balance_due': fields.float('Due balance', required=True, readonly=True),
'mail_message_id': fields.many2one('mail.message', 'Sent Email', readonly=True),
'mail_message_id': fields.many2one('mail.mail', 'Sent Email', readonly=True),
'move_line_id': fields.many2one('account.move.line', 'Move line',
required=True, readonly=True),

View File

@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author: Nicolas Bessi, Guewen Baconnier
# Copyright 2012 Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import orm, fields
class Mail(orm.Model):
_inherit = 'mail.mail'
# use HTML fields instead of text
_columns = {'body_html': fields.html('Rich-text Contents',
help="Rich-text/HTML message"),}

View File

@@ -56,7 +56,7 @@ class CreditCommunication(TransientModel):
if isinstance(com_id, list):
com_id = com_id[0]
form = self.browse(cr, uid, com_id, context=context)
email = form.partner_id.id or False
email = form.partner_id.email or False
return email
def _get_credit_lines(self, cr, uid, line_ids, partner_id, level_id, context=None):
@@ -101,7 +101,7 @@ class CreditCommunication(TransientModel):
"""Generate email message using template related to level"""
cr_line_obj = self.pool.get('credit.control.line')
email_temp_obj = self.pool.get('email.template')
email_message_obj = self.pool.get('mail.message')
email_message_obj = self.pool.get('mail.mail')
email_ids = []
essential_fields = ['subject',
'body_html',
@@ -118,6 +118,8 @@ class CreditCommunication(TransientModel):
template,
comm.id,
context=context)
email_values['body_html'] = email_values['body']
email_values['type'] = 'email'
email_id = email_message_obj.create(cr, uid, email_values, context=context)