diff --git a/addons/account_followup/account_followup.py b/addons/account_followup/account_followup.py
index 17a09d51e6e..30bd543f7ca 100644
--- a/addons/account_followup/account_followup.py
+++ b/addons/account_followup/account_followup.py
@@ -113,66 +113,6 @@ class account_move_line(osv.osv):
}
-
-class email_template(osv.osv):
- _inherit = 'email.template'
-
- def _get_followup_table_html(self, cr, uid, res_id, context=None):
- '''
- Build the html tables to be included in emails send to partners, when reminding them their
- overdue invoices.
-
- :param res_id: ID of the partner for whom we are building the tables
- :rtype: string
- '''
- from report import account_followup_print
-
- partner = self.pool.get('res.partner').browse(cr, uid, res_id, context=context)
- followup_table = ''
- if partner.unreconciled_aml_ids:
- company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id
- current_date = fields.date.context_today(cr, uid, context)
- rml_parse = account_followup_print.report_rappel(cr, uid, "followup_rml_parser")
- final_res = rml_parse._lines_get_with_partner(partner, company.id)
-
- for currency_dict in final_res:
- currency = currency_dict.get('line', [{'currency_id': company.currency_id}])[0]['currency_id']
- followup_table += '''
-
-
- | Invoice date |
- Reference |
- Due date |
- Amount (%s) |
- Lit. |
-
- ''' % (currency.symbol)
- total = 0
- for aml in currency_dict['line']:
- block = aml['blocked'] and 'X' or ' '
- total += aml['balance']
- strbegin = ""
- strend = " | "
- date = aml['date_maturity'] or aml['date']
- if date <= current_date and aml['balance'] > 0:
- strbegin = ""
- strend = " | "
- followup_table +="" + strbegin + str(aml['date']) + strend + strbegin + aml['ref'] + strend + strbegin + str(date) + strend + strbegin + str(aml['balance']) + strend + strbegin + block + strend + "
"
- total = rml_parse.formatLang(total, dp='Account', currency_obj=currency)
- followup_table += '''
-
- Amount due: %s ''' % (total)
- return followup_table
-
-
- def render_template(self, cr, uid, template, model, res_id, context=None):
- if model == 'res.partner' and context.get('followup'):
- context['followup_table'] = self._get_followup_table_html(cr, uid, res_id, context=context)
- # Adds current_date to the context. That way it can be used to put
- # the account move lines in bold that are overdue in the email
- context['current_date'] = fields.date.context_today(cr, uid, context)
- return super(email_template, self).render_template(cr, uid, template, model, res_id, context=context)
-
class res_partner(osv.osv):
def fields_view_get(self, cr, uid, view_id=None, view_type=None, context=None, toolbar=False, submenu=False):
@@ -289,6 +229,52 @@ class res_partner(osv.osv):
'payment_next_action': payment_next_action}, context=ctx)
return unknown_mails
+ def get_followup_table_html(self, cr, uid, ids, context=None):
+ """ Build the html tables to be included in emails send to partners,
+ when reminding them their overdue invoices.
+ :param ids: [id] of the partner for whom we are building the tables
+ :rtype: string
+ """
+ from report import account_followup_print
+
+ assert len(ids) == 1
+ partner = self.browse(cr, uid, ids[0], context=context)
+ followup_table = ''
+ if partner.unreconciled_aml_ids:
+ company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id
+ current_date = fields.date.context_today(cr, uid, context)
+ rml_parse = account_followup_print.report_rappel(cr, uid, "followup_rml_parser")
+ final_res = rml_parse._lines_get_with_partner(partner, company.id)
+
+ for currency_dict in final_res:
+ currency = currency_dict.get('line', [{'currency_id': company.currency_id}])[0]['currency_id']
+ followup_table += '''
+
+
+ | Invoice date |
+ Reference |
+ Due date |
+ Amount (%s) |
+ Lit. |
+
+ ''' % (currency.symbol)
+ total = 0
+ for aml in currency_dict['line']:
+ block = aml['blocked'] and 'X' or ' '
+ total += aml['balance']
+ strbegin = ""
+ strend = " | "
+ date = aml['date_maturity'] or aml['date']
+ if date <= current_date and aml['balance'] > 0:
+ strbegin = ""
+ strend = " | "
+ followup_table +="" + strbegin + str(aml['date']) + strend + strbegin + aml['ref'] + strend + strbegin + str(date) + strend + strbegin + str(aml['balance']) + strend + strbegin + block + strend + "
"
+ total = rml_parse.formatLang(total, dp='Account', currency_obj=currency)
+ followup_table += '''
+
+ Amount due: %s ''' % (total)
+ return followup_table
+
def action_done(self, cr, uid, ids, context=None):
return self.write(cr, uid, ids, {'payment_next_action_date': False, 'payment_next_action':'', 'payment_responsible_id': False}, context=context)
diff --git a/addons/account_followup/account_followup_data.xml b/addons/account_followup/account_followup_data.xml
index c35a0ffcd49..d7e6d029ae9 100644
--- a/addons/account_followup/account_followup_data.xml
+++ b/addons/account_followup/account_followup_data.xml
@@ -34,7 +34,7 @@ ${user.name}
-${ctx.get('followup_table','') | safe}
+${object.get_followup_table_html() | safe}
@@ -74,7 +74,7 @@ ${user.name}
-${ctx.get('followup_table','') | safe}
+${object.get_followup_table_html() | safe}
@@ -111,7 +111,7 @@ ${user.name}
-${ctx.get('followup_table','') | safe}
+${object.get_followup_table_html() | safe}
@@ -146,7 +146,7 @@ ${user.name}
-${ctx.get('followup_table','') | safe}
+${object.get_followup_table_html() | safe}