diff --git a/account_credit_control/data.xml b/account_credit_control/data.xml index de9e8ee7e..e92be1b2d 100644 --- a/account_credit_control/data.xml +++ b/account_credit_control/data.xml @@ -9,8 +9,7 @@ - %if mode != 'pdf': + %if mode and mode != 'pdf': @@ -24,7 +23,7 @@ - + diff --git a/account_credit_control/i18n/account_credit_control.pot b/account_credit_control/i18n/account_credit_control.pot index 2cc7c34c8..1dae32a8d 100644 --- a/account_credit_control/i18n/account_credit_control.pot +++ b/account_credit_control/i18n/account_credit_control.pot @@ -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" -" \n" -" \n" -" %endif\n" -"
\n" -"\n" -"

Dear ${object.partner_id.name or ''},

\n" -"\n" -"
${object.current_policy_level.custom_text}
\n" -"\n" -"
Summary
date dueDate due Amount due Amount balance Invoice number
\n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -" \n" -"%for line in object.credit_control_line_ids:\n" -" \n" -" \n" -" \n" -" \n" -" %if line.invoice_id:\n" -" \n" -" %else:\n" -" \n" -" %endif\n" -"%endfor\n" -"
Summary
date dueAmount dueAmount balanceInvoice number
${line.date_due}${line.amount_due}${line.balance_due}${line.invoice_id.number}n/a
\n" -"
\n" -"
\n" -"\n" -"

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

\n" -"\n" -"

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

\n" -"\n" -" -- more info here --\n" -"

${object.user_id.name} ${object.user_id.user_email and '<%s>'%(object.user_id.user_email) or ''}
\n" -" ${object.company_id.name}
\n" -" % if object.company_id.street:\n" -" ${object.company_id.street or ''}
\n" -"\n" -" % endif\n" -"\n" -" % if object.company_id.street2:\n" -" ${object.company_id.street2}
\n" -" % endif\n" -" % if object.company_id.city or object.company_id.zip:\n" -" ${object.company_id.zip or ''} ${object.company_id.city or ''}
\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 ''}
\n" -" % endif\n" -" % if object.company_id.phone:\n" -" Phone: ${object.company_id.phone}
\n" -" % endif\n" -" % if object.company_id.website:\n" -" ${object.company_id.website or ''}
\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 "" - diff --git a/account_credit_control/report/credit_control_summary.html.mako b/account_credit_control/report/credit_control_summary.html.mako index 5f3b602f4..9fd14d15a 100644 --- a/account_credit_control/report/credit_control_summary.html.mako +++ b/account_credit_control/report/credit_control_summary.html.mako @@ -2,6 +2,120 @@ @@ -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'"/> diff --git a/account_credit_control/wizard/credit_control_communication.py b/account_credit_control/wizard/credit_control_communication.py index 75808a999..31a6b88d3 100644 --- a/account_credit_control/wizard/credit_control_communication.py +++ b/account_credit_control/wizard/credit_control_communication.py @@ -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)