From 3b97ea2c676d746fc34b6ac8c687d5c2aadf2b3f Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 12 Jul 2013 08:28:24 +0200 Subject: [PATCH] [IMP] reporting layer, + add hook function to get contact address --- account_credit_control/data.xml | 80 +++++++++---------- .../report/credit_control_summary.html.mako | 19 +++-- .../wizard/credit_control_communication.py | 19 +++-- 3 files changed, 65 insertions(+), 53 deletions(-) diff --git a/account_credit_control/data.xml b/account_credit_control/data.xml index f01c91253..542bdc708 100644 --- a/account_credit_control/data.xml +++ b/account_credit_control/data.xml @@ -4,7 +4,7 @@ Credit Control Email noreply@localhost - Credit Control: (${object.current_policy_level.name or 'n/a' }) + Credit Control: (${object.current_policy_level.name or 'n/a'}) ${object.get_email() or ''} @@ -31,7 +31,8 @@ .basic_table th { border: 1px solid lightGrey; - font-size: 12px; + font-size: 11px; + font-weight: bold; } .basic_table td { @@ -41,6 +42,7 @@ td.amount, th.amount { text-align: right; + padding-right: 2px; white-space: nowrap; } @@ -52,19 +54,12 @@ %endif
- - <% - def carriage_returns(text): - return text.replace('\n', '
') - %> - -

+

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

+ -

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

- -

${object.current_policy_level.custom_text | carriage_returns }

+

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

+

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



@@ -72,21 +67,32 @@ - - - - + + + + + + + %for line in object.credit_control_line_ids: + %if line.invoice_id: + + %else: + + %endif + - %if line.invoice_id: - - %else: - - %endif + + %endfor
Summary
Date dueAmount dueAmount balanceInvoice numberInvoice 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.invoice_id.number}n/a${line.currency_id.name or object.company_id.currency_id.name}

@@ -143,8 +149,7 @@ email - Dear Sir or Madam, - + 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. @@ -163,9 +168,8 @@ Best regards, email - Dear Sir or Madam, - -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. + +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. @@ -183,8 +187,7 @@ Best regards, letter - Dear Sir or Madam, - + 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. @@ -213,12 +216,9 @@ Best regards, email - Dear Sir or Madam, - -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. + +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. @@ -235,13 +235,11 @@ Best regards, letter - Dear Sir or Madam, + +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 (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 +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. diff --git a/account_credit_control/report/credit_control_summary.html.mako b/account_credit_control/report/credit_control_summary.html.mako index a45c5b775..98d055be2 100644 --- a/account_credit_control/report/credit_control_summary.html.mako +++ b/account_credit_control/report/credit_control_summary.html.mako @@ -65,7 +65,7 @@ table { .list_table th { border-bottom: 2px solid black; text-align: left; - font-size: 12px; + font-size: 11px; font-weight: bold; padding-right: 3px padding-left: 3px @@ -105,6 +105,7 @@ table .address_title { td.amount, th.amount { text-align: right; + padding-right:2px; } h1 { @@ -129,13 +130,17 @@ tr.line { <% setLang(comm.partner_id.lang) %>
- %if comm.partner_id.parent_id: - - - <% address_lines = comm.partner_id.contact_address.split("\n")[1:] %> + <% + add = comm.get_contact_address() + %> + %if comm.partner_id.id == add.id: + + <% address_lines = comm.partner_id.contact_address.split("\n") %> + %else: - - <% address_lines = comm.partner_id.contact_address.split("\n") %> + + + <% address_lines = add.contact_address.split("\n")[1:] %> %endif %for part in address_lines: %if part: diff --git a/account_credit_control/wizard/credit_control_communication.py b/account_credit_control/wizard/credit_control_communication.py index be64414f6..ef3ce6792 100644 --- a/account_credit_control/wizard/credit_control_communication.py +++ b/account_credit_control/wizard/credit_control_communication.py @@ -26,7 +26,7 @@ logger = logging.getLogger('credit.control.line.mailing') class CreditCommunication(TransientModel): - """Shell calss used to provide a base model to email template and reporting. + """Shell class used to provide a base model to email template and reporting. Il use this approche in version 7 a browse record will exist even if not saved""" _name = "credit.control.communication" _description = "credit control communication" @@ -51,13 +51,22 @@ class CreditCommunication(TransientModel): 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), \ - "com_id: only one id expected" + if isinstance(com_id, list): + 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) + return contact.email + + def get_contact_address(self, cr, uid, com_id, context=None): + pmod = self.pool['res.partner'] if isinstance(com_id, list): com_id = com_id[0] form = self.browse(cr, uid, com_id, context=context) - email = form.partner_id.email or False - return email + part = form.partner_id + add_ids = part.address_get(adr_pref=['invoice']) or {} + add_id = add_ids.get('invoice', add_ids.get('default', False)) + return pmod.browse(cr, uid, add_id, context) def _get_credit_lines(self, cr, uid, line_ids, partner_id, level_id, context=None): """Return credit lines related to a partner and a policy level"""
${comm.partner_id.parent_id.name or ''}
${comm.partner_id.title and comm.partner_id.title.name or ''} ${comm.partner_id.name }
${comm.partner_id.title and comm.partner_id.title.name or ''} ${comm.partner_id.name }
${comm.partner_id.title and comm.partner_id.title.name or ''} ${comm.partner_id.name }
${comm.partner_id.name or ''}
${add.title and add.title.name or ''} ${add.name}