From 1d6338589a19579684abb0d0e2bc0ad70e30c947 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 12 Jul 2013 12:44:13 +0200 Subject: [PATCH] [REFACTOR] credit control mail are not in plain text but send as attachement --- account_credit_control/__openerp__.py | 4 +- account_credit_control/data.xml | 233 +++++++----------- account_credit_control/policy.py | 3 + account_credit_control/policy_view.xml | 5 +- .../report/credit_control_summary.html.mako | 98 ++++++-- .../wizard/credit_control_communication.py | 20 +- 6 files changed, 193 insertions(+), 170 deletions(-) diff --git a/account_credit_control/__openerp__.py b/account_credit_control/__openerp__.py index 00de80a48..5da57004a 100644 --- a/account_credit_control/__openerp__.py +++ b/account_credit_control/__openerp__.py @@ -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': [], diff --git a/account_credit_control/data.xml b/account_credit_control/data.xml index 542bdc708..9090fbacf 100644 --- a/account_credit_control/data.xml +++ b/account_credit_control/data.xml @@ -8,122 +8,13 @@ ${object.get_email() or ''} + ${object.get_contact_address().lang.code or 'en_US'} + - - %endif -
-

- Credit Control: ${object.current_policy_level.name or 'n/a' } -

- -

Dear ${object.get_contact_address().name or ''},

-

${object.current_policy_level.custom_text.replace('\n', '
')}

- + Dear ${object.get_contact_address().name or ''}

- - - - - - - - - - - - -%for line in object.credit_control_line_ids: - - %if line.invoice_id: - - %else: - - %endif - - - - - - -%endfor -
Summary
Invoice numberInvoice dateDate dueInvoiced AmountOpen AmountCurrency
${line.invoice_id.number} - %if line.invoice_id.name: -
- ${line.invoice_id.name} - %endif -
${line.move_line_id.name}${line.date_entry}${line.date_due}${line.amount_due}${line.balance_due}${line.currency_id.name or object.company_id.currency_id.name}
-
-
- -

If you have any question, do not hesitate to contact us.

- -

Thank you for choosing ${object.company_id.name}!

- -

${object.user_id.name} ${object.user_id.email and '<%s>'%(object.user_id.email) or ''}
- ${object.company_id.name}
- % if object.company_id.street: - ${object.company_id.street or ''}
- - % endif - - % if object.company_id.street2: - ${object.company_id.street2}
- % endif - % if object.company_id.city or object.company_id.zip: - ${object.company_id.zip or ''} ${object.company_id.city or ''}
- % 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 ''}
- % endif - % if object.company_id.phone: - Phone: ${object.company_id.phone}
- % endif - % if object.company_id.website: - ${object.company_id.website or ''}
- % endif + ${object.current_policy_level.custom_mail_text} ]]> @@ -149,14 +40,22 @@ email - -Our records indicate that we have not received the payment of the above mentioned invoice (copy attached for your convenience). + 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, - +Best regards + + + 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 + email - -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. + 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, - +Best regards + + 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 + letter -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, - + Best regards + + +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 + @@ -216,14 +133,20 @@ Best regards, email - -Our records indicate that we have not received the payment of the above mentioned invoice (copy attached for your convenience). + 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 + + 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, - +Best regards + letter - -Our records indicate that we still have not received the payment of the above mentioned invoice (copy attached) despite our reminder. + 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 + + 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, - + Best regards + - Credit Control Manager - + Credit Control Manager + - Credit Control User - + Credit Control User + - Credit Control Info - + Credit Control Info + - + diff --git a/account_credit_control/policy.py b/account_credit_control/policy.py index cf312d504..b1eff26d7 100644 --- a/account_credit_control/policy.py +++ b/account_credit_control/policy.py @@ -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): diff --git a/account_credit_control/policy_view.xml b/account_credit_control/policy_view.xml index 5e12f4516..9808da98c 100644 --- a/account_credit_control/policy_view.xml +++ b/account_credit_control/policy_view.xml @@ -32,7 +32,10 @@ - + + + + diff --git a/account_credit_control/report/credit_control_summary.html.mako b/account_credit_control/report/credit_control_summary.html.mako index 98d055be2..9acce13b5 100644 --- a/account_credit_control/report/credit_control_summary.html.mako +++ b/account_credit_control/report/credit_control_summary.html.mako @@ -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 {

+
+
+
- <% - 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'"/> + +

+ ${_('Reminder')}: ${comm.current_policy_level.name or '' } +

+ +

${_('Dear')} ${comm.get_contact_address().name or ''},

+

${comm.current_policy_level.custom_text.replace('\n', '
')}

+ +
+
+ + + + + + + + + + + + +%for line in comm.credit_control_line_ids: + + %if line.invoice_id: + + %else: + + %endif + + + + + + +%endfor +
${_('Summary')}
${_('Invoice number')}${_('Invoice date')}${_('Date due')}${_('Invoiced Amount')}${_('Open Amount')}${_('Currency')}
${line.invoice_id.number} + %if line.invoice_id.name: +
+ ${line.invoice_id.name} + %endif +
${line.move_line_id.name}${line.date_entry}${line.date_due}${line.amount_due}${line.balance_due}${line.currency_id.name or comm.company_id.currency_id.name}
+
+
+<%doc> + +

${_('If you have any question, do not hesitate to contact us.')}

+ +

${comm.user_id.name} ${comm.user_id.email and '<%s>'%(comm.user_id.email) or ''}
+ ${comm.company_id.name}
+ % if comm.company_id.street: + ${comm.company_id.street or ''}
+ + % endif + + % if comm.company_id.street2: + ${comm.company_id.street2}
+ % endif + % if comm.company_id.city or comm.company_id.zip: + ${comm.company_id.zip or ''} ${comm.company_id.city or ''}
+ % 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 ''}
+ % endif + % if comm.company_id.phone: + Phone: ${comm.company_id.phone}
+ % endif + % if comm.company_id.website: + ${comm.company_id.website or ''}
+ % endif +

%endfor diff --git a/account_credit_control/wizard/credit_control_communication.py b/account_credit_control/wizard/credit_control_communication.py index ef3ce6792..4b0e3cdee 100644 --- a/account_credit_control/wizard/credit_control_communication.py +++ b/account_credit_control/wizard/credit_control_communication.py @@ -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