mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[REFACTOR] credit control mail are not in plain text but send as attachement
This commit is contained in:
@@ -58,7 +58,8 @@ On each generated line, you have many choices:
|
||||
* Change the state (so you can ignore or reopen lines)
|
||||
""",
|
||||
'website': 'http://www.camptocamp.com',
|
||||
'data': ["data.xml",
|
||||
'data': ["report/report.xml",
|
||||
"data.xml",
|
||||
"line_view.xml",
|
||||
"account_view.xml",
|
||||
"partner_view.xml",
|
||||
@@ -68,7 +69,6 @@ On each generated line, you have many choices:
|
||||
"wizard/credit_control_emailer_view.xml",
|
||||
"wizard/credit_control_marker_view.xml",
|
||||
"wizard/credit_control_printer_view.xml",
|
||||
"report/report.xml",
|
||||
"security/ir.model.access.csv"],
|
||||
'demo_xml': ["credit_control_demo.xml"],
|
||||
'tests': [],
|
||||
|
||||
@@ -8,122 +8,13 @@
|
||||
<field name="email_to">${object.get_email() or ''}</field>
|
||||
<field name="model_id" ref="model_credit_control_communication"/>
|
||||
<field name="auto_delete" eval="True"/>
|
||||
<field name="lang">${object.get_contact_address().lang.code or 'en_US'}</field>
|
||||
<field name="report_template" ref="report_webkit_html"/>
|
||||
<field name="body_html"><![CDATA[
|
||||
%if mode and mode != 'pdf':
|
||||
<!-- your css here -->
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family: helvetica;
|
||||
font-size: 11px;
|
||||
}
|
||||
.custom_text {
|
||||
font-family: helvetica;
|
||||
font-size: 11px;
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
.basic_table {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
border: 1px solid lightGrey;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.basic_table th {
|
||||
border: 1px solid lightGrey;
|
||||
font-size: 11px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.basic_table td {
|
||||
border: 1px solid lightGrey;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
td.amount, th.amount {
|
||||
text-align: right;
|
||||
padding-right: 2px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
th.date {
|
||||
}
|
||||
td.date {
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
%endif
|
||||
<div>
|
||||
<h3 style="clear: both; padding-top: 20px;">
|
||||
Credit Control: ${object.current_policy_level.name or 'n/a' }
|
||||
</h3>
|
||||
|
||||
<p>Dear ${object.get_contact_address().name or ''},</p>
|
||||
<p class="custom_text" width="95%">${object.current_policy_level.custom_text.replace('\n', '<br />')}</p>
|
||||
|
||||
Dear ${object.get_contact_address().name or ''}
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<table class="basic_table" style="width: 100%;">
|
||||
<caption><b>Summary</b></caption>
|
||||
<tr>
|
||||
<th width="200">Invoice number</th>
|
||||
<th>Invoice date</th>
|
||||
<th>Date due</th>
|
||||
<th>Invoiced Amount</th>
|
||||
<th>Open Amount</th>
|
||||
<th>Currency</th>
|
||||
|
||||
</tr>
|
||||
%for line in object.credit_control_line_ids:
|
||||
<tr>
|
||||
%if line.invoice_id:
|
||||
<td width="200">${line.invoice_id.number}
|
||||
%if line.invoice_id.name:
|
||||
<br/>
|
||||
${line.invoice_id.name}
|
||||
%endif
|
||||
</td>
|
||||
%else:
|
||||
<td width="200">${line.move_line_id.name}</td>
|
||||
%endif
|
||||
<td class="date">${line.date_entry}</td>
|
||||
<td class="date">${line.date_due}</td>
|
||||
<td class="amount">${line.amount_due}</td>
|
||||
<td class="amount">${line.balance_due}</td>
|
||||
<td class="amount">${line.currency_id.name or object.company_id.currency_id.name}</td>
|
||||
</tr>
|
||||
%endfor
|
||||
</table>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<p>If you have any question, do not hesitate to contact us.</p>
|
||||
|
||||
<p>Thank you for choosing ${object.company_id.name}! </p>
|
||||
|
||||
<p>${object.user_id.name} ${object.user_id.email and '<%s>'%(object.user_id.email) or ''}<br/>
|
||||
${object.company_id.name}<br/>
|
||||
% if object.company_id.street:
|
||||
${object.company_id.street or ''}<br/>
|
||||
|
||||
% endif
|
||||
|
||||
% if object.company_id.street2:
|
||||
${object.company_id.street2}<br/>
|
||||
% endif
|
||||
% if object.company_id.city or object.company_id.zip:
|
||||
${object.company_id.zip or ''} ${object.company_id.city or ''}<br/>
|
||||
% endif
|
||||
% if object.company_id.country_id:
|
||||
${object.company_id.state_id and ('%s, ' % object.company_id.state_id.name) or ''} ${object.company_id.country_id.name or ''}<br/>
|
||||
% endif
|
||||
% if object.company_id.phone:
|
||||
Phone: ${object.company_id.phone}<br/>
|
||||
% endif
|
||||
% if object.company_id.website:
|
||||
${object.company_id.website or ''}<br/>
|
||||
% endif
|
||||
${object.current_policy_level.custom_mail_text}
|
||||
]]></field>
|
||||
</record>
|
||||
|
||||
@@ -149,14 +40,22 @@
|
||||
<field name="email_template_id" ref="email_template_credit_control_base"/>
|
||||
<field name="policy_id" ref="credit_control_3_time"/>
|
||||
<field name="channel">email</field>
|
||||
<field name="custom_text">
|
||||
Our records indicate that we have not received the payment of the above mentioned invoice (copy attached for your convenience).
|
||||
<field name="custom_text">Our records indicate that we have not received the payment of the above mentioned invoice.
|
||||
If it has already been sent, please disregard this notice. If not, please proceed with payment within 10 days.
|
||||
|
||||
Thank you in advance for your anticipated cooperation in this matter.
|
||||
|
||||
Best regards,
|
||||
</field>
|
||||
Best regards
|
||||
</field>
|
||||
|
||||
<field name="custom_mail_text">Our records indicate that we have not received the payment of the above mentioned invoice (copy attached for your convenience).
|
||||
|
||||
If it has already been sent, please disregard this notice. If not, please proceed with payment within 10 days.
|
||||
|
||||
Thank you in advance for your anticipated cooperation in this matter.
|
||||
|
||||
Best regards
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="credit.control.policy.level"
|
||||
@@ -168,14 +67,20 @@ Best regards,
|
||||
<field name="email_template_id" ref="email_template_credit_control_base"/>
|
||||
<field name="policy_id" ref="credit_control_3_time"/>
|
||||
<field name="channel">email</field>
|
||||
<field name="custom_text">
|
||||
Our records indicate that we have not yet received the payment of the above mentioned invoice (copy attached for your convenience) despite our first reminder.
|
||||
If it has already been sent, please disregard this notice. If not, please proceed with payment within 5 days.
|
||||
<field name="custom_text">Our records indicate that we have not yet received the payment of the above mentioned invoice despite our first reminder.
|
||||
If it has already been sent, please disregard this notice. If not, please proceed with payment within 5 days.
|
||||
|
||||
Thank you in advance for your anticipated cooperation in this matter.
|
||||
|
||||
Best regards,
|
||||
</field>
|
||||
Best regards
|
||||
</field>
|
||||
<field name="custom_mail_text">Our records indicate that we have not yet received the payment of the above mentioned invoice (copy attached for your convenience) despite our first reminder.
|
||||
If it has already been sent, please disregard this notice. If not, please proceed with payment within 5 days.
|
||||
|
||||
Thank you in advance for your anticipated cooperation in this matter.
|
||||
|
||||
Best regards
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="credit.control.policy.level"
|
||||
@@ -188,17 +93,29 @@ Best regards,
|
||||
<field name="policy_id" ref="credit_control_3_time"/>
|
||||
<field name="channel">letter</field>
|
||||
<field name="custom_text">
|
||||
Our records indicate that we still have not received the payment of the above mentioned invoice (copy attached) despite our two reminders.
|
||||
If payment have already been sent, please disregard this notice. If not, please proceed with payment.
|
||||
If your payment has not been received in the next 5 days, your file will be transfered to our debt collection agency.
|
||||
Our records indicate that we still have not received the payment of the above mentioned invoice despite our two reminders.
|
||||
If payment have already been sent, please disregard this notice. If not, please proceed with payment.
|
||||
If your payment has not been received in the next 5 days, your file will be transfered to our debt collection agency.
|
||||
|
||||
Should you need us to arrange a payment plan for you, please advise.
|
||||
A customer account statement is enclosed for you convenience.
|
||||
Should you need us to arrange a payment plan for you, please advise.
|
||||
A customer account statement is enclosed for you convenience.
|
||||
|
||||
Thank you in advance for your anticipated cooperation in this matter.
|
||||
Thank you in advance for your anticipated cooperation in this matter.
|
||||
|
||||
Best regards,
|
||||
</field>
|
||||
Best regards
|
||||
</field>
|
||||
|
||||
<field name="custom_mail_text">Our records indicate that we still have not received the payment of the above mentioned invoice (copy attached) despite our two reminders.
|
||||
If payment have already been sent, please disregard this notice. If not, please proceed with payment.
|
||||
If your payment has not been received in the next 5 days, your file will be transfered to our debt collection agency.
|
||||
|
||||
Should you need us to arrange a payment plan for you, please advise.
|
||||
A customer account statement is enclosed for you convenience.
|
||||
|
||||
Thank you in advance for your anticipated cooperation in this matter.
|
||||
|
||||
Best regards
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- policy 2 -->
|
||||
@@ -216,14 +133,20 @@ Best regards,
|
||||
<field name="email_template_id" ref="email_template_credit_control_base"/>
|
||||
<field name="policy_id" ref="credit_control_2_time"/>
|
||||
<field name="channel">email</field>
|
||||
<field name="custom_text">
|
||||
Our records indicate that we have not received the payment of the above mentioned invoice (copy attached for your convenience).
|
||||
<field name="custom_text">Our records indicate that we have not received the payment of the above mentioned invoice.
|
||||
If it has already been sent, please disregard this notice. If not, please proceed with payment within 10 days.
|
||||
|
||||
Thank you in advance for your anticipated cooperation in this matter.
|
||||
|
||||
Best regards
|
||||
</field>
|
||||
<field name="custom_mail_text">Our records indicate that we have not received the payment of the above mentioned invoice (copy attached for your convenience).
|
||||
If it has already been sent, please disregard this notice. If not, please proceed with payment within 10 days.
|
||||
|
||||
Thank you in advance for your anticipated cooperation in this matter.
|
||||
|
||||
Best regards,
|
||||
</field>
|
||||
Best regards
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="credit.control.policy.level"
|
||||
@@ -235,39 +158,51 @@ Best regards,
|
||||
<field name="email_template_id" ref="email_template_credit_control_base"/>
|
||||
<field name="policy_id" ref="credit_control_2_time"/>
|
||||
<field name="channel">letter</field>
|
||||
<field name="custom_text">
|
||||
Our records indicate that we still have not received the payment of the above mentioned invoice (copy attached) despite our reminder.
|
||||
<field name="custom_text">Our records indicate that we still have not received the payment of the above mentioned invoice despite our reminder.
|
||||
|
||||
If payment have already been sent, please disregard this notice. If not, please proceed with payment.
|
||||
If your payment has not been received in the next 5 days, your file will be transfered to our debt
|
||||
collection agency.
|
||||
|
||||
Should you need us to arrange a payment plan for you, please advise.
|
||||
A customer account statement is enclosed for you convenience.
|
||||
|
||||
Thank you in advance for your anticipated cooperation in this matter.
|
||||
|
||||
Best regards
|
||||
</field>
|
||||
<field name="custom_mail_text">Our records indicate that we still have not received the payment of the above mentioned invoice (copy attached) despite our reminder.
|
||||
|
||||
If payment have already been sent, please disregard this notice. If not, please proceed with payment.
|
||||
If your payment has not been received in the next 5 days, your file will be transfered to our debt
|
||||
collection agency.
|
||||
collection agency.
|
||||
|
||||
Should you need us to arrange a payment plan for you, please advise.
|
||||
A customer account statement is enclosed for you convenience.
|
||||
Should you need us to arrange a payment plan for you, please advise.
|
||||
A customer account statement is enclosed for you convenience.
|
||||
|
||||
Thank you in advance for your anticipated cooperation in this matter.
|
||||
Thank you in advance for your anticipated cooperation in this matter.
|
||||
|
||||
Best regards,
|
||||
</field>
|
||||
Best regards
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="group_account_credit_control_manager" model="res.groups">
|
||||
<field name="name">Credit Control Manager</field>
|
||||
<field name="category_id" ref="base.module_category_accounting_and_finance"/>
|
||||
<field name="name">Credit Control Manager</field>
|
||||
<field name="category_id" ref="base.module_category_accounting_and_finance"/>
|
||||
</record>
|
||||
|
||||
<record id="group_account_credit_control_user" model="res.groups" context="{'noadmin':True}">
|
||||
<field name="name">Credit Control User</field>
|
||||
<field name="category_id" ref="base.module_category_accounting_and_finance"/>
|
||||
<field name="name">Credit Control User</field>
|
||||
<field name="category_id" ref="base.module_category_accounting_and_finance"/>
|
||||
</record>
|
||||
|
||||
<record id="group_account_credit_control_info" model="res.groups" context="{'noadmin':True}">
|
||||
<field name="name">Credit Control Info</field>
|
||||
<field name="category_id" ref="base.module_category_accounting_and_finance"/>
|
||||
<field name="name">Credit Control Info</field>
|
||||
<field name="category_id" ref="base.module_category_accounting_and_finance"/>
|
||||
</record>
|
||||
|
||||
<record id="base.main_company" model="res.company">
|
||||
<field name="credit_policy_id" ref="credit_control_3_time"/>
|
||||
<field name="credit_policy_id" ref="credit_control_3_time"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
|
||||
@@ -227,6 +227,9 @@ class CreditControlPolicyLevel(Model):
|
||||
('email', 'Email')],
|
||||
'Channel', required=True),
|
||||
'custom_text': fields.text('Custom Message', required=True, translate=True),
|
||||
'custom_mail_text': fields.text('Custom Mail Message',
|
||||
required=True, translate=True),
|
||||
|
||||
}
|
||||
|
||||
def _check_level_mode(self, cr, uid, rids, context=None):
|
||||
|
||||
@@ -32,7 +32,10 @@
|
||||
</page>
|
||||
<page string="Mail and reporting">
|
||||
<field name="email_template_id"/>
|
||||
<field name="custom_text"/>
|
||||
<newline/>
|
||||
<field name="custom_text" colspan="4"/>
|
||||
<newline/>
|
||||
<field name="custom_mail_text" colspan="4"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
${css}
|
||||
body {
|
||||
font-family: helvetica;
|
||||
font-size: 11px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.custom_text {
|
||||
font-family: helvetica;
|
||||
font-size: 11px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
table {
|
||||
font-family: helvetica;
|
||||
font-size: 11px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.header {
|
||||
@@ -33,11 +33,15 @@ table {
|
||||
text-align: center;
|
||||
border: 1px solid lightGrey;
|
||||
border-collapse: collapse;
|
||||
font-family: helvetica;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.basic_table th {
|
||||
border: 1px solid lightGrey;
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
font-weight: bold;
|
||||
|
||||
}
|
||||
|
||||
.basic_table td {
|
||||
@@ -154,19 +158,81 @@ tr.line {
|
||||
<br/>
|
||||
|
||||
</div>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
<div>
|
||||
<%
|
||||
setLang(comm.partner_id.lang)
|
||||
current_uri = '%s_policy_template' % (comm.partner_id.lang)
|
||||
if not context.lookup.has_template(current_uri):
|
||||
# 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'"/>
|
||||
|
||||
<h3 style="clear: both; padding-top: 20px;">
|
||||
${_('Reminder')}: ${comm.current_policy_level.name or '' }
|
||||
</h3>
|
||||
|
||||
<p>${_('Dear')} ${comm.get_contact_address().name or ''},</p>
|
||||
<p class="custom_text" width="95%">${comm.current_policy_level.custom_text.replace('\n', '<br />')}</p>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<table class="basic_table" style="width: 100%;">
|
||||
<caption><b>${_('Summary')}<br/></b></caption>
|
||||
<tr>
|
||||
<th width="200">${_('Invoice number')}</th>
|
||||
<th>${_('Invoice date')}</th>
|
||||
<th>${_('Date due')}</th>
|
||||
<th>${_('Invoiced Amount')}</th>
|
||||
<th>${_('Open Amount')}</th>
|
||||
<th>${_('Currency')}</th>
|
||||
|
||||
</tr>
|
||||
%for line in comm.credit_control_line_ids:
|
||||
<tr>
|
||||
%if line.invoice_id:
|
||||
<td width="200">${line.invoice_id.number}
|
||||
%if line.invoice_id.name:
|
||||
<br/>
|
||||
${line.invoice_id.name}
|
||||
%endif
|
||||
</td>
|
||||
%else:
|
||||
<td width="200">${line.move_line_id.name}</td>
|
||||
%endif
|
||||
<td class="date">${line.date_entry}</td>
|
||||
<td class="date">${line.date_due}</td>
|
||||
<td class="amount">${line.amount_due}</td>
|
||||
<td class="amount">${line.balance_due}</td>
|
||||
<td class="amount">${line.currency_id.name or comm.company_id.currency_id.name}</td>
|
||||
</tr>
|
||||
%endfor
|
||||
</table>
|
||||
<br/>
|
||||
<br/>
|
||||
<%doc>
|
||||
<!-- uncomment to have info after summary -->
|
||||
<p>${_('If you have any question, do not hesitate to contact us.')}</p>
|
||||
|
||||
<p>${comm.user_id.name} ${comm.user_id.email and '<%s>'%(comm.user_id.email) or ''}<br/>
|
||||
${comm.company_id.name}<br/>
|
||||
% if comm.company_id.street:
|
||||
${comm.company_id.street or ''}<br/>
|
||||
|
||||
% endif
|
||||
|
||||
% if comm.company_id.street2:
|
||||
${comm.company_id.street2}<br/>
|
||||
% endif
|
||||
% if comm.company_id.city or comm.company_id.zip:
|
||||
${comm.company_id.zip or ''} ${comm.company_id.city or ''}<br/>
|
||||
% endif
|
||||
% if comm.company_id.country_id:
|
||||
${comm.company_id.state_id and ('%s, ' % comm.company_id.state_id.name) or ''} ${comm.company_id.country_id.name or ''}<br/>
|
||||
% endif
|
||||
% if comm.company_id.phone:
|
||||
Phone: ${comm.company_id.phone}<br/>
|
||||
% endif
|
||||
% if comm.company_id.website:
|
||||
${comm.company_id.website or ''}<br/>
|
||||
% endif
|
||||
</%doc>
|
||||
|
||||
<p style="page-break-after:always"></p>
|
||||
%endfor
|
||||
|
||||
@@ -55,7 +55,7 @@ class CreditCommunication(TransientModel):
|
||||
assert len(com_id) == 1, "get_email only support one id as parameter"
|
||||
com_id = com_id[0]
|
||||
form = self.browse(cr, uid, com_id, context=context)
|
||||
contact = self.get_contact_address(form.partner_id.id, context=context)
|
||||
contact = form.get_contact_address()
|
||||
return contact.email
|
||||
|
||||
def get_contact_address(self, cr, uid, com_id, context=None):
|
||||
@@ -111,6 +111,7 @@ class CreditCommunication(TransientModel):
|
||||
cr_line_obj = self.pool.get('credit.control.line')
|
||||
email_temp_obj = self.pool.get('email.template')
|
||||
email_message_obj = self.pool.get('mail.mail')
|
||||
att_obj = self.pool.get('ir.attachment')
|
||||
email_ids = []
|
||||
essential_fields = ['subject',
|
||||
'body_html',
|
||||
@@ -145,7 +146,22 @@ class CreditCommunication(TransientModel):
|
||||
{'mail_message_id': email_id,
|
||||
'state': state},
|
||||
context=context)
|
||||
|
||||
att_ids = []
|
||||
for att in email_values.get('attachments', []):
|
||||
attach_fname = att[0]
|
||||
attach_datas = att[1]
|
||||
data_attach = {
|
||||
'name': attach_fname,
|
||||
'datas': attach_datas,
|
||||
'datas_fname': attach_fname,
|
||||
'res_model': 'mail.mail',
|
||||
'res_id': email_id,
|
||||
'type': 'binary',
|
||||
}
|
||||
att_ids.append(att_obj.create(cr, uid, data_attach, context=context))
|
||||
email_message_obj.write(cr, uid, [email_id],
|
||||
{'attachment_ids': [(6, 0, att_ids)]},
|
||||
context=context)
|
||||
email_ids.append(email_id)
|
||||
return email_ids
|
||||
|
||||
|
||||
Reference in New Issue
Block a user