diff --git a/addons/account_followup/report/account_followup_print.py b/addons/account_followup/report/account_followup_print.py index 30cbe058fd4..54ead894c67 100644 --- a/addons/account_followup/report/account_followup_print.py +++ b/addons/account_followup/report/account_followup_print.py @@ -50,13 +50,40 @@ class report_rappel(report_sxw.rml_parse): return adr and res_partner_address.read(self.cr, self.uid, [adr]) or [{}] def _lines_get(self, partner): - moveline_obj = pooler.get_pool(self.cr.dbname).get('account.move.line') + pool = pooler.get_pool(self.cr.dbname) + moveline_obj = pool.get('account.move.line') + company_obj = pool.get('res.company') + obj_currency = pool.get('res.currency') + #FIXME: search on company accounting entries only movelines = moveline_obj.search(self.cr, self.uid, [('partner_id', '=', partner.id), ('account_id.type', '=', 'receivable'), ('reconcile_id', '=', False), ('state', '<>', 'draft')]) - movelines = moveline_obj.read(self.cr, self.uid, movelines) - return movelines + movelines = moveline_obj.browse(self.cr, self.uid, movelines) + base_currency = movelines[0].company_id.currency_id + final_res = [] + line_cur = {base_currency.id: {'line': []}} + + for line in movelines: + if line.currency_id and (not line.currency_id.id in line_cur): + line_cur[line.currency_id.id] = {'line': []} + currency = line.currency_id or line.company_id.currency_id + line_data = { + 'name': line.name, + 'ref': line.ref, + 'date':line.date, + 'date_maturity': line.date_maturity, + 'balance': line.currency_id and line.amount_currency or (line.debit - line.credit), + 'blocked': line.blocked, + 'currency_id': currency.symbol or currency.name, + } + line_cur[currency.id]['line'].append(line_data) + + for cur in line_cur: + if line_cur[cur]['line']: + final_res.append({'line': line_cur[cur]['line']}) + return final_res + def _get_text(self, partner, followup_id, context=None): fp_obj = pooler.get_pool(self.cr.dbname).get('account_followup.followup') diff --git a/addons/account_followup/report/account_followup_print.rml b/addons/account_followup/report/account_followup_print.rml index 08dae5a82bc..812f0aa0e50 100644 --- a/addons/account_followup/report/account_followup_print.rml +++ b/addons/account_followup/report/account_followup_print.rml @@ -56,6 +56,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -77,8 +108,8 @@ - - + + @@ -86,14 +117,15 @@ - - + + [[ repeatIn(ids_to_objects(data['form']['partner_ids']),'o') ]] [[ setLang(o.lang) ]] + @@ -126,13 +158,16 @@ - +
+ + + [[repeatIn(getLines(o), 'cur_lines') ]] Invoice Date - Description + Description Ref @@ -141,31 +176,21 @@ Maturity Date - Currency - - - Due - - - Paid - - - Maturity + Amount Li. -
- [[repeatIn(getLines(o), 'line') ]] - - + + + [[repeatIn(cur_lines['line'], 'line') ]] - [[ formatLang(line['date'],date = True) ]] + [[ formatLang(line['date'],date = True) ]] - [[ line['name'] ]] + [[ line['name'] ]] [[ line['ref'] ]] @@ -174,24 +199,14 @@ [[ line['date_maturity'] and formatLang(line['date_maturity'], date=True) ]] - [[ formatLang(line['amount_currency'] )]] [[ line['amount_currency'] and line['currency_id'][1] or '' ]] - - - [[ formatLang(line['debit']) ]] - - - [[ formatLang(line['credit']) ]] - - - [[ (line['date_maturity'] < time.strftime('%Y-%m-%d')) and formatLang(line['debit'] -line['credit']) or formatLang(0.0) ]] [[ company.currency_id.symbol ]] + [[ formatLang(line['balance']) ]] [[ line['currency_id'] ]] [[ line['blocked'] and 'X' or '' ]] -
- + @@ -199,16 +214,10 @@ - Sub-Total: + Total: - [[formatLang(reduce(lambda x,y: x+y['debit'], getLines(o), 0.00)) ]] - - - [[formatLang(reduce(lambda x,y: x+y['credit'], getLines(o), 0.00)) ]] - - - [[ formatLang(reduce(lambda x,y: x+(y['debit'] - y['credit']), filter(lambda x: x['date_maturity'] < time.strftime('%Y-%m-%d'), getLines(o)), 0)) ]] [[ company.currency_id.symbol ]] + [[formatLang(reduce(lambda x,y: x+y['balance'], cur_lines['line'], 0.00)) ]] [[ line['currency_id'] ]] @@ -217,25 +226,18 @@ - - - - - - - - - Balance: - - - [[ formatLang((reduce(lambda x,y: x+(y['debit'] - y['credit']), getLines(o), 0.00))) ]] [[ company.currency_id.symbol]] - - - - - - - - + + + + + + + + + + + +
+
- \ No newline at end of file +