diff --git a/addons/account_followup/report/account_followup_print.py b/addons/account_followup/report/account_followup_print.py index 30cbe058fd4..c2818c886f2 100644 --- a/addons/account_followup/report/account_followup_print.py +++ b/addons/account_followup/report/account_followup_print.py @@ -50,13 +50,45 @@ 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') 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': []} + line_data = { + 'name': line.name + (line.currency_id and line.currency_id.name or ''), + 'ref': line.ref, + 'date':line.date, + 'date_maturity': line.date_maturity, + 'amount_currency': line.amount_currency, + 'blocked': line.blocked, + 'debit': line.debit , + 'credit': line.credit, + } + if line.currency_id: + rate = obj_currency._get_conversion_rate(self.cr, self.uid, line.company_id.currency_id, line.currency_id) + line_data['debit'] = line.debit * rate + line_data['credit'] = line.credit * rate + line_data.update({'currency_id':line.currency_id.symbol or line.currency_id.name or ''}) + line_cur[line.currency_id.id]['line'].append(line_data) + else: + line_data.update({'currency_id':line.company_id.currency_id.symbol or line.currency_id.name or ''}) + line_cur[base_currency.id]['line'].append(line_data) + for cur in line_cur: + 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..be8ab854fe7 100644 --- a/addons/account_followup/report/account_followup_print.rml +++ b/addons/account_followup/report/account_followup_print.rml @@ -94,6 +94,7 @@ [[ repeatIn(ids_to_objects(data['form']['partner_ids']),'o') ]] [[ setLang(o.lang) ]] + @@ -126,7 +127,10 @@ - +
+ + + [[repeatIn(getLines(o), 'cur_lines') ]] Invoice Date @@ -140,9 +144,6 @@ Maturity Date - - Currency - Due @@ -156,11 +157,8 @@ Li. - -
- [[repeatIn(getLines(o), 'line') ]] - - + + [[repeatIn(cur_lines['line'], 'line') ]] [[ formatLang(line['date'],date = True) ]] @@ -174,24 +172,20 @@ [[ 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']) ]] [[ line['currency_id'] ]] - [[ formatLang(line['debit']) ]] + [[ formatLang(line['credit']) ]] [[ line['currency_id'] ]] - [[ 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 ]] + [[ (line['date_maturity'] < time.strftime('%Y-%m-%d')) and formatLang(line['debit'] -line['credit']) or formatLang(0.0) ]] [[ line['currency_id'] or '']] [[ line['blocked'] and 'X' or '' ]] -
- + @@ -202,13 +196,13 @@ Sub-Total: - [[formatLang(reduce(lambda x,y: x+y['debit'], getLines(o), 0.00)) ]] + [[formatLang(reduce(lambda x,y: x+y['debit'], cur_lines['line'], 0.00)) ]] [[ line['currency_id'] ]] - [[formatLang(reduce(lambda x,y: x+y['credit'], getLines(o), 0.00)) ]] + [[formatLang(reduce(lambda x,y: x+y['credit'], cur_lines['line'], 0.00)) ]] [[ line['currency_id'] ]] - [[ 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['debit'] - y['credit']), filter(lambda x: x['date_maturity'] < time.strftime('%Y-%m-%d'), cur_lines['line']), 0)) ]] [[ line['currency_id'] ]] @@ -217,7 +211,7 @@ - + @@ -228,14 +222,41 @@ Balance: - [[ formatLang((reduce(lambda x,y: x+(y['debit'] - y['credit']), getLines(o), 0.00))) ]] [[ company.currency_id.symbol]] + + [[ formatLang((reduce(lambda x,y: x+(y['debit'] - y['credit']), cur_lines['line'], 0.00))) ]] [[line['currency_id'] ]] + + + + + + + + + + + + + + + + + + + + + + + + +
+
- \ No newline at end of file +