[FIX] mail + print of remeinder

This commit is contained in:
unknown
2013-06-06 15:52:26 +02:00
parent 8ab9aefb91
commit d2ec82f983
4 changed files with 130 additions and 110 deletions

View File

@@ -9,8 +9,7 @@
<field name="model_id" ref="model_credit_control_communication"/>
<field name="auto_delete" eval="True"/>
<field name="body_html"><![CDATA[
<%page args="object, user=None, ctx=None, quote=None, format_exception=True, mode='email'" />
%if mode != 'pdf':
%if mode and mode != 'pdf':
<!-- your css here -->
<style type="text/css">
</style>
@@ -24,7 +23,7 @@
<table style="border: 1px solid" width="100%">
<caption><b>Summary</b></caption>
<tr>
<th>date due</th>
<th>Date due</th>
<th>Amount due</th>
<th>Amount balance</th>
<th>Invoice number</th>

View File

@@ -562,79 +562,6 @@ msgstr ""
msgid "Run date"
msgstr ""
#. module: account_credit_control
#: model:res.groups,name:account_credit_control.group_account_credit_control_user
msgid "Credit Control User"
msgstr ""
#. module: account_credit_control
#: model:email.template,body_html:account_credit_control.email_template_credit_control_base
msgid "\n"
" <%page args=\"object, user=None, ctx=None, quote=None, format_exception=True, mode='mail'\" />\n"
" %if mode != 'pdf':\n"
" <!-- your css here -->\n"
" <style type=\"text/css\">\n"
" </style>\n"
" %endif\n"
" <div>\n"
"\n"
" <p>Dear ${object.partner_id.name or ''},</p>\n"
"\n"
" <pre class=\"custom_text\">${object.current_policy_level.custom_text}</pre>\n"
"\n"
" <table style=\"border: 1px solid\" width=\"100%\">\n"
" <caption><b>Summary</b></caption>\n"
" <tr>\n"
" <th>date due</th>\n"
" <th>Amount due</th>\n"
" <th>Amount balance</th>\n"
" <th>Invoice number</th>\n"
" </tr>\n"
"%for line in object.credit_control_line_ids:\n"
" <tr>\n"
" <td>${line.date_due}</td>\n"
" <td>${line.amount_due}</td>\n"
" <td>${line.balance_due}</td>\n"
" %if line.invoice_id:\n"
" <td>${line.invoice_id.number}</td>\n"
" %else:\n"
" <td>n/a</td>\n"
" %endif\n"
"%endfor\n"
" </table>\n"
" <br/>\n"
" <br/>\n"
"\n"
" <p>If you have any question, do not hesitate to contact us.</p>\n"
"\n"
" <p>Thank you for choosing ${object.company_id.name}! </p>\n"
"\n"
" -- more info here --\n"
" <p>${object.user_id.name} ${object.user_id.user_email and '<%s>'%(object.user_id.user_email) or ''}<br/>\n"
" ${object.company_id.name}<br/>\n"
" % if object.company_id.street:\n"
" ${object.company_id.street or ''}<br/>\n"
"\n"
" % endif\n"
"\n"
" % if object.company_id.street2:\n"
" ${object.company_id.street2}<br/>\n"
" % endif\n"
" % if object.company_id.city or object.company_id.zip:\n"
" ${object.company_id.zip or ''} ${object.company_id.city or ''}<br/>\n"
" % endif\n"
" % if object.company_id.country_id:\n"
" ${object.company_id.state_id and ('%s, ' % object.company_id.state_id.name) or ''} ${object.company_id.country_id.name or ''}<br/>\n"
" % endif\n"
" % if object.company_id.phone:\n"
" Phone: ${object.company_id.phone}<br/>\n"
" % endif\n"
" % if object.company_id.website:\n"
" ${object.company_id.website or ''}<br/>\n"
" % endif\n"
" "
msgstr ""
#. module: account_credit_control
#: constraint:account.move.line:0
msgid "Company must be the same for its related account and period."
@@ -784,4 +711,3 @@ msgstr ""
#: field:credit.control.line,policy_level_id:0
msgid "Overdue Level"
msgstr ""

View File

@@ -2,6 +2,120 @@
<head>
<style type="text/css">
${css}
body {
font-family: helvetica;
font-size: 11px;
}
table {
font-family: helvetica;
font-size: 11px;
}
.header {
margin-left: 0px;
text-align: left;
width: 300px;
font-size: 12px;
}
.title {
font-size: 16px;
font-weight: bold;
}
.basic_table{
text-align: center;
border: 1px solid lightGrey;
border-collapse: collapse;
}
.basic_table th {
border: 1px solid lightGrey;
font-size: 12px;
}
.basic_table td {
border: 1px solid lightGrey;
font-size: 12px;
}
.list_table {
border-color: black;
text-align: center;
border-collapse: collapse;
}
.list_table td {
border-color: gray;
border-top: 1px solid gray;
text-align: left;
font-size: 12px;
padding-right: 3px;
padding-left: 3px;
padding-top: 3px;
padding-bottom:3px;
}
.list_table th {
border-bottom: 2px solid black;
text-align: left;
font-size: 12px;
font-weight: bold;
padding-right: 3px
padding-left: 3px
}
.list_table thead {
display: table-header-group;
}
.address table {
font-size: 11px;
border-collapse: collapse;
margin: 0px;
padding: 0px;
}
.address .shipping {
}
.address .invoice {
margin-top: 10px;
}
.address .recipient {
margin-right: 120px;
float: right;
}
table .address_title {
font-weight: bold;
}
.address td.name {
font-weight: bold;
}
td.amount, th.amount {
text-align: right;
}
h1 {
font-size: 16px;
font-weight: bold;
}
tr.line .note {
border-style: none;
font-size: 9px;
padding-left: 10px;
}
tr.line {
margin-bottom: 10px;
}
</style>
</head>
<body>
@@ -11,7 +125,12 @@
setLang(comm.partner_id.lang)
current_uri = '%s_policy_template' % (comm.partner_id.lang)
if not context.lookup.has_template(current_uri):
context.lookup.put_string(current_uri, comm.current_policy_level.email_template_id.body_html)
# awfully horrible we add page tags here beacause openerp replaced
# mako by Jinga but not everywere so they sandbox mako into jinga
# and jinga prevent %page tag to wwork
context.lookup.put_string(current_uri,
"""<%page args="object, user=None, ctx=None, quote=None, format_exception=True, mode='email'" />
""" + comm.current_policy_level.email_template_id.body_html)
%>
<%include file="${current_uri}" args="object=comm,user=user,ctx=ctx,quote=quote,format_exception=format_exception,mode='pdf'"/>

View File

@@ -49,24 +49,6 @@ class CreditCommunication(TransientModel):
cr, uid, 'credit.control.policy', context=c),
'user_id': lambda s, cr, uid, c: uid}
def get_address(self, cr, uid, com_id, context=None):
"""Return a valid address for customer"""
assert not (isinstance(com_id, list) and len(com_id) > 1), \
"com_id: only one id expected"
if isinstance(com_id, list):
com_id = com_id[0]
form = self.browse(cr, uid, com_id, context=context)
part_obj = self.pool.get('res.partner')
adds = part_obj.address_get(cr, uid, [form.partner_id.id],
adr_pref=['invoice', 'default'])
add = adds.get('invoice', adds.get('default'))
add_obj = self.pool.get('res.partner.address')
if add:
return add_obj.browse(cr, uid, add, context=context)
else:
return False
def get_email(self, cr, uid, com_id, context=None):
"""Return a valid email for customer"""
assert not (isinstance(com_id, list) and len(com_id) > 1), \
@@ -74,10 +56,7 @@ class CreditCommunication(TransientModel):
if isinstance(com_id, list):
com_id = com_id[0]
form = self.browse(cr, uid, com_id, context=context)
address = form.get_address()
email = ''
if address and address.email:
email = address.email
email = form.partner_id.id or False
return email
def _get_credit_lines(self, cr, uid, line_ids, partner_id, level_id, context=None):
@@ -124,13 +103,10 @@ class CreditCommunication(TransientModel):
email_temp_obj = self.pool.get('email.template')
email_message_obj = self.pool.get('mail.message')
email_ids = []
essential_fields = [
'subject',
'body_html',
'email_from',
'email_to'
]
essential_fields = ['subject',
'body_html',
'email_from',
'email_to']
for comm in comms:
# we want to use a local cr in order to send the maximum
@@ -139,9 +115,9 @@ class CreditCommunication(TransientModel):
email_values = {}
cl_ids = [cl.id for cl in comm.credit_control_line_ids]
email_values = email_temp_obj.generate_email(cr, uid,
template,
comm.id,
context=context)
template,
comm.id,
context=context)
email_id = email_message_obj.create(cr, uid, email_values, context=context)