From 915451ba1697d85466662e746fbb6385fbf4bca5 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Tue, 22 Mar 2011 16:40:23 +0530 Subject: [PATCH 1/3] [IMP]:Account:multi currency report feature improvement(send follow ups) bzr revid: ron@tinyerp.com-20110322111023-d3phue8nql33gdwr --- .../report/account_followup_print.py | 38 ++++++++++- .../report/account_followup_print.rml | 67 ++++++++++++------- 2 files changed, 79 insertions(+), 26 deletions(-) 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 + From cf33670162f1beeae7feb643ea9bddc604ff7ea4 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Wed, 23 Mar 2011 15:43:41 +0100 Subject: [PATCH 2/3] [FIX][IMP] account_followup: improved the layout and overal shape of report + fixed the way to display amount in currency other than company (should use amount_currency field instead of (debit-credit * rate)) bzr revid: qdp-launchpad@openerp.com-20110323144341-425n7h1rkrpj4s1s --- .../report/account_followup_print.py | 22 +++---- .../report/account_followup_print.rml | 64 ++----------------- 2 files changed, 14 insertions(+), 72 deletions(-) diff --git a/addons/account_followup/report/account_followup_print.py b/addons/account_followup/report/account_followup_print.py index c2818c886f2..9ad0e4bd480 100644 --- a/addons/account_followup/report/account_followup_print.py +++ b/addons/account_followup/report/account_followup_print.py @@ -54,6 +54,7 @@ class report_rappel(report_sxw.rml_parse): 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'), @@ -62,29 +63,22 @@ class report_rappel(report_sxw.rml_parse): 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 + (line.currency_id and line.currency_id.name or ''), + 'name': line.name, 'ref': line.ref, 'date':line.date, 'date_maturity': line.date_maturity, - 'amount_currency': line.amount_currency, + 'balance': line.currency_id and line.amount_currency or (line.debit - line.credit), 'blocked': line.blocked, - 'debit': line.debit , - 'credit': line.credit, + 'currency_id': currency.symbol or currency.name, } - 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) + line_cur[currency.id]['line'].append(line_data) + for cur in line_cur: final_res.append({'line': line_cur[cur]['line']}) return final_res diff --git a/addons/account_followup/report/account_followup_print.rml b/addons/account_followup/report/account_followup_print.rml index be8ab854fe7..dd4aefb39e5 100644 --- a/addons/account_followup/report/account_followup_print.rml +++ b/addons/account_followup/report/account_followup_print.rml @@ -129,7 +129,7 @@
- + [[repeatIn(getLines(o), 'cur_lines') ]] @@ -145,13 +145,7 @@ Maturity Date - Due - - - Paid - - - Maturity + Amount Li. @@ -172,20 +166,14 @@ [[ line['date_maturity'] and formatLang(line['date_maturity'], date=True) ]] - [[ formatLang(line['debit']) ]] [[ line['currency_id'] ]] - - - [[ formatLang(line['credit']) ]] [[ line['currency_id'] ]] - - - [[ (line['date_maturity'] < time.strftime('%Y-%m-%d')) and formatLang(line['debit'] -line['credit']) or formatLang(0.0) ]] [[ line['currency_id'] or '']] + [[ formatLang(line['balance']) ]] [[ line['currency_id'] ]] [[ line['blocked'] and 'X' or '' ]] - + @@ -193,16 +181,10 @@ - Sub-Total: + Total: - [[formatLang(reduce(lambda x,y: x+y['debit'], cur_lines['line'], 0.00)) ]] [[ line['currency_id'] ]] - - - [[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'), cur_lines['line']), 0)) ]] [[ line['currency_id'] ]] + [[formatLang(reduce(lambda x,y: x+y['balance'], cur_lines['line'], 0.00)) ]] [[ line['currency_id'] ]] @@ -211,41 +193,7 @@ - - - - - - - - - Balance: - - - [[ formatLang((reduce(lambda x,y: x+(y['debit'] - y['credit']), cur_lines['line'], 0.00))) ]] [[line['currency_id'] ]] - - - - - - - - - - - - - - - - - - - - - - From 9e4ae35beb42ac045e202649ad7e56808ff25564 Mon Sep 17 00:00:00 2001 From: "ron@tinyerp.com" <> Date: Fri, 25 Mar 2011 18:12:35 +0530 Subject: [PATCH 3/3] [IMP]Account followup:Improvement of report style and shape bzr revid: ron@tinyerp.com-20110325124235-2niq7ivqgirr6vv0 --- .../report/account_followup_print.py | 3 +- .../report/account_followup_print.rml | 51 +++++++++++++++---- 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/addons/account_followup/report/account_followup_print.py b/addons/account_followup/report/account_followup_print.py index 9ad0e4bd480..54ead894c67 100644 --- a/addons/account_followup/report/account_followup_print.py +++ b/addons/account_followup/report/account_followup_print.py @@ -80,7 +80,8 @@ class report_rappel(report_sxw.rml_parse): line_cur[currency.id]['line'].append(line_data) for cur in line_cur: - final_res.append({'line': line_cur[cur]['line']}) + if line_cur[cur]['line']: + final_res.append({'line': line_cur[cur]['line']}) return final_res diff --git a/addons/account_followup/report/account_followup_print.rml b/addons/account_followup/report/account_followup_print.rml index dd4aefb39e5..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,8 +117,8 @@ - - + + @@ -129,14 +160,14 @@
- + [[repeatIn(getLines(o), 'cur_lines') ]] Invoice Date - Description + Description Ref @@ -151,13 +182,15 @@ Li. + + [[repeatIn(cur_lines['line'], 'line') ]] - [[ formatLang(line['date'],date = True) ]] + [[ formatLang(line['date'],date = True) ]] - [[ line['name'] ]] + [[ line['name'] ]] [[ line['ref'] ]] @@ -181,7 +214,7 @@ - Total: + Total: [[formatLang(reduce(lambda x,y: x+y['balance'], cur_lines['line'], 0.00)) ]] [[ line['currency_id'] ]]