From abe9469e889c2698234ecbb4aeecc1058b9cf66b Mon Sep 17 00:00:00 2001 From: pso Date: Fri, 19 Nov 2010 15:17:58 +0530 Subject: [PATCH 1/7] [IMP] account: Improved partner and general ledger reports for account currency bzr revid: pso@tinyerp.com-20101119094758-n54crq4lq41he265 --- .../account/report/account_general_ledger.py | 8 +++-- .../account_general_ledger_landscape.rml | 2 +- .../account/report/account_partner_ledger.py | 33 +++++++++++++------ .../report/account_partner_ledger_other.rml | 7 ++-- 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/addons/account/report/account_general_ledger.py b/addons/account/report/account_general_ledger.py index 6ccfb9343a2..a1e6aca6433 100644 --- a/addons/account/report/account_general_ledger.py +++ b/addons/account/report/account_general_ledger.py @@ -191,17 +191,19 @@ class general_ledger(report_sxw.rml_parse, common_report_header): sql = """ SELECT 0 AS lid, '' AS ldate, '' AS lcode, COALESCE(SUM(l.amount_currency),0.0) AS amount_currency, '' AS lref, 'Initial Balance' AS lname, COALESCE(SUM(l.debit),0.0) AS debit, COALESCE(SUM(l.credit),0.0) AS credit, '' AS lperiod_id, '' AS lpartner_id, '' AS move_name, '' AS mmove_id, - '' AS currency_code, - NULL AS currency_id, + c.symbol AS currency_code, + '' AS currency_id, '' AS invoice_id, '' AS invoice_type, '' AS invoice_number, '' AS partner_name FROM account_move_line l LEFT JOIN account_move m on (l.move_id=m.id) + LEFT JOIN account_account ac on (l.account_id=ac.id) LEFT JOIN res_currency c on (l.currency_id=c.id) LEFT JOIN res_partner p on (l.partner_id=p.id) LEFT JOIN account_invoice i on (m.id =i.move_id) JOIN account_journal j on (l.journal_id=j.id) - WHERE %s AND m.state IN %s AND l.account_id = %%s + WHERE %s AND m.state IN %s AND l.account_id = %%s + group by c.symbol """ %(self.init_query, tuple(move_state)) self.cr.execute(sql, (account.id,)) res_init = self.cr.dictfetchall() diff --git a/addons/account/report/account_general_ledger_landscape.rml b/addons/account/report/account_general_ledger_landscape.rml index 430bde219e1..02e720f016e 100644 --- a/addons/account/report/account_general_ledger_landscape.rml +++ b/addons/account/report/account_general_ledger_landscape.rml @@ -327,7 +327,7 @@ [[ formatLang(line['debit'], digits=get_digits(dp='Account')) ]] [[ formatLang(line['credit'], digits=get_digits(dp='Account')) ]] [[ formatLang(line['progress'], digits=get_digits(dp='Account')) ]] [[ company.currency_id.symbol ]] - [[ (line.has_key('currency_id') and line['currency_id']==None or line['amount_currency']==None) and removeParentNode('font') ]] [[ formatLang(line['amount_currency'])]] [[ line['currency_code'] or '']] + [[ (o.currency_id and formatLang(line['amount_currency'])) or removeParentNode('font') ]] [[ line['currency_code'] or '']] diff --git a/addons/account/report/account_partner_ledger.py b/addons/account/report/account_partner_ledger.py index e66c3a9d523..8db8189ac9c 100644 --- a/addons/account/report/account_partner_ledger.py +++ b/addons/account/report/account_partner_ledger.py @@ -50,6 +50,7 @@ class third_party_ledger(report_sxw.rml_parse, common_report_header): 'display_initial_balance':self._display_initial_balance, 'display_currency':self._display_currency, 'get_target_move': self._get_target_move, + 'sum_currency_amount_account': self._sum_currency_amount_account }) def set_context(self, objects, data, ids, report_type=None): @@ -178,7 +179,8 @@ class third_party_ledger(report_sxw.rml_parse, common_report_header): " " + RECONCILE_TAG + " "\ "AND " + self.init_query + " ", (partner.id, tuple(move_state), tuple(self.account_ids))) - return self.cr.fetchall() + res = self.cr.fetchall() + return res def _sum_debit_partner(self, partner): move_state = ['draft','posted'] @@ -385,16 +387,27 @@ class third_party_ledger(report_sxw.rml_parse, common_report_header): return 'Receivable and Payable Accounts' return '' - def _sum_currency_amount_account(self, account, form): - self._set_get_account_currency_code(account.id) - self.cr.execute("SELECT sum(aml.amount_currency) FROM account_move_line as aml,res_currency as rc WHERE aml.currency_id = rc.id AND aml.account_id= %s ", (account.id,)) +# def _set_get_account_currency_code(self, account_id): +# self.cr.execute("SELECT c.symbol AS code "\ +# "FROM res_currency c, account_account AS ac "\ +# "WHERE ac.id = %s AND ac.currency_id = c.id" % (account_id)) +# result = self.cr.fetchone() +# if result: +# self.account_currency = result[0] +# else: +# self.account_currency = False + + def _sum_currency_amount_account(self, account): +# self._set_get_account_currency_code(account.id) + self.cr.execute("SELECT sum(aml.amount_currency) FROM account_move_line as aml,res_currency as rc WHERE aml.currency_id = rc.id AND aml.account_id= %s" %(account.id)) total = self.cr.fetchone() - if self.account_currency: - return_field = str(total[0]) + self.account_currency - return return_field - else: - currency_total = self.tot_currency = 0.0 - return currency_total + return total[0] or 0.0 +# if self.amount_currency: +# return_field = total[0] + self.amount_currency +# return return_field +# else: +# currency_total = self.tot_currency = 0.0 +# return currency_total def _display_initial_balance(self, data): if self.initial_balance: diff --git a/addons/account/report/account_partner_ledger_other.rml b/addons/account/report/account_partner_ledger_other.rml index c3315dde64d..36aadc9e0dc 100644 --- a/addons/account/report/account_partner_ledger_other.rml +++ b/addons/account/report/account_partner_ledger_other.rml @@ -327,7 +327,8 @@ - + + @@ -656,7 +657,7 @@ [[ formatLang(get_intial_balance(p)[0][2]) ]] [[ company.currency_id.symbol ]] - + [[ p.property_account_receivable.currency_id and formatLang(sum_currency_amount_account(p.property_account_receivable), digits=get_digits(dp='Account')) + p.property_account_receivable.currency_id.symbol or '' ]] @@ -689,7 +690,7 @@ [[ formatLang((line['progress'])) ]] [[ company.currency_id.symbol ]] - [[ (line['currency_id']==None or line['amount_currency']==None) and removeParentNode('font') ]] [[ formatLang(line['amount_currency'] ) ]] [[ line['currency_code'] or '' ]] + [[ (p.property_account_receivable.currency_id and formatLang(line['amount_currency'])) or removeParentNode('font') ]] [[ line['currency_code'] or '']] From 216fe9522dbe0fa73c5778b4a81bf4da0215ab62 Mon Sep 17 00:00:00 2001 From: pso Date: Fri, 19 Nov 2010 15:31:19 +0530 Subject: [PATCH 2/7] [IMP] account: removed unnecessary var bzr revid: pso@tinyerp.com-20101119100119-1fs913166qqc1dvm --- addons/account/report/account_partner_ledger.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/account/report/account_partner_ledger.py b/addons/account/report/account_partner_ledger.py index 8db8189ac9c..415597e3201 100644 --- a/addons/account/report/account_partner_ledger.py +++ b/addons/account/report/account_partner_ledger.py @@ -179,8 +179,7 @@ class third_party_ledger(report_sxw.rml_parse, common_report_header): " " + RECONCILE_TAG + " "\ "AND " + self.init_query + " ", (partner.id, tuple(move_state), tuple(self.account_ids))) - res = self.cr.fetchall() - return res + return self.cr.fetchall() def _sum_debit_partner(self, partner): move_state = ['draft','posted'] From 4482eeec0565301ada78bef83b2ef7ab341fc7d8 Mon Sep 17 00:00:00 2001 From: pso Date: Fri, 19 Nov 2010 17:36:16 +0530 Subject: [PATCH 3/7] [IMP] account: Improved general ledger report bzr revid: pso@tinyerp.com-20101119120616-tbtwepubi2224ny8 --- addons/account/report/account_general_ledger.rml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/report/account_general_ledger.rml b/addons/account/report/account_general_ledger.rml index 2a3bfda8e48..feeaa1fa18c 100644 --- a/addons/account/report/account_general_ledger.rml +++ b/addons/account/report/account_general_ledger.rml @@ -340,7 +340,7 @@ [[formatLang(sum_debit_account(o)) ]] [[formatLang(sum_credit_account(o)) ]] [[formatLang(sum_balance_account(o)) ]] [[ company.currency_id.symbol ]] - [[ o.currency_id and sum_currency_amount_account(o) +o.currency_id.symbol or '' ]] + [[ (o.currency_id and formatLang(sum_currency_amount_account(o))) or removeParentNode('font') ]] [[ o.currency_id.symbol or '']] From 971d02737ad087fd0c62d379f03c89bb5b543cf3 Mon Sep 17 00:00:00 2001 From: pso Date: Fri, 19 Nov 2010 18:58:58 +0530 Subject: [PATCH 4/7] [IMP] account: Improved general ledger report bzr revid: pso@tinyerp.com-20101119132858-58rfm2hxtd1xha52 --- addons/account/report/account_general_ledger_landscape.rml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/report/account_general_ledger_landscape.rml b/addons/account/report/account_general_ledger_landscape.rml index 02e720f016e..e91bedb4a5d 100644 --- a/addons/account/report/account_general_ledger_landscape.rml +++ b/addons/account/report/account_general_ledger_landscape.rml @@ -301,7 +301,7 @@ [[ formatLang(sum_debit_account(o), digits=get_digits(dp='Account')) ]] [[ formatLang(sum_credit_account(o), digits=get_digits(dp='Account')) ]] [[ formatLang(sum_balance_account(o), digits=get_digits(dp='Account')) ]] [[ company.currency_id.symbol ]] - [[ o.currency_id and formatLang(sum_currency_amount_account(o), digits=get_digits(dp='Account')) + o.currency_id.code or '' ]] + [[ o.currency_id and formatLang(sum_currency_amount_account(o), digits=get_digits(dp='Account')) + o.currency_id.symbol or '' ]] From 6b0d611eb15d8afda66c92648e95fac60d359c19 Mon Sep 17 00:00:00 2001 From: pso Date: Tue, 23 Nov 2010 12:49:48 +0530 Subject: [PATCH 5/7] [IMP] account: Improved general and partner ledger reports for currency bzr revid: pso@tinyerp.com-20101123071948-v6c42bqfn0wvcj7x --- .../account/report/account_general_ledger.py | 29 ++++++++++++++----- .../account/report/account_general_ledger.rml | 4 +-- .../account_general_ledger_landscape.rml | 3 +- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/addons/account/report/account_general_ledger.py b/addons/account/report/account_general_ledger.py index a1e6aca6433..4052fa650f9 100644 --- a/addons/account/report/account_general_ledger.py +++ b/addons/account/report/account_general_ledger.py @@ -170,13 +170,20 @@ class general_ledger(report_sxw.rml_parse, common_report_header): else: sql_sort='l.date' sql = """ - SELECT l.id AS lid, l.date AS ldate, j.code AS lcode, l.currency_id,l.amount_currency,l.ref AS lref, l.name AS lname, COALESCE(l.debit,0) AS debit, COALESCE(l.credit,0) AS credit, l.period_id AS lperiod_id, l.partner_id AS lpartner_id, + SELECT l.id AS lid, l.date AS ldate, j.code AS lcode, l.currency_id, + case when a.currency_id is not null then + l.amount_currency + else + 0.0 + end as amount_currency, + l.ref AS lref, l.name AS lname, COALESCE(l.debit,0) AS debit, COALESCE(l.credit,0) AS credit, l.period_id AS lperiod_id, l.partner_id AS lpartner_id, m.name AS move_name, m.id AS mmove_id, c.symbol AS currency_code, i.id AS invoice_id, i.type AS invoice_type, i.number AS invoice_number, p.name AS partner_name FROM account_move_line l JOIN account_move m on (l.move_id=m.id) + LEFT JOIN account_account a ON (l.account_id=a.id) LEFT JOIN res_currency c on (l.currency_id=c.id) LEFT JOIN res_partner p on (l.partner_id=p.id) LEFT JOIN account_invoice i on (m.id =i.move_id) @@ -189,25 +196,31 @@ class general_ledger(report_sxw.rml_parse, common_report_header): if res_lines and self.init_balance: #FIXME: replace the label of lname with a string translatable sql = """ - SELECT 0 AS lid, '' AS ldate, '' AS lcode, COALESCE(SUM(l.amount_currency),0.0) AS amount_currency, '' AS lref, 'Initial Balance' AS lname, COALESCE(SUM(l.debit),0.0) AS debit, COALESCE(SUM(l.credit),0.0) AS credit, '' AS lperiod_id, '' AS lpartner_id, - '' AS move_name, '' AS mmove_id, + SELECT 0 AS lid, '' AS ldate, '' AS lcode, + sum(case when a.currency_id is not null then + l.amount_currency + else + 0.0 + end) as amount_currency, + '' AS lref, 'Initial Balance' AS lname, COALESCE(SUM(l.debit),0.0) AS debit, COALESCE(SUM(l.credit),0.0) AS credit, '' AS lperiod_id, '' AS lpartner_id, + '' AS move_name, '' AS mmove_id, c.symbol AS currency_code, - '' AS currency_id, + l.currency_id AS currency_id, '' AS invoice_id, '' AS invoice_type, '' AS invoice_number, '' AS partner_name FROM account_move_line l LEFT JOIN account_move m on (l.move_id=m.id) - LEFT JOIN account_account ac on (l.account_id=ac.id) + LEFT JOIN account_account a ON (l.account_id=a.id) LEFT JOIN res_currency c on (l.currency_id=c.id) LEFT JOIN res_partner p on (l.partner_id=p.id) LEFT JOIN account_invoice i on (m.id =i.move_id) JOIN account_journal j on (l.journal_id=j.id) WHERE %s AND m.state IN %s AND l.account_id = %%s - group by c.symbol + group by c.symbol , l.currency_id """ %(self.init_query, tuple(move_state)) self.cr.execute(sql, (account.id,)) res_init = self.cr.dictfetchall() - res = res_init + res_lines + res = res_init + res_lines account_sum = 0.0 inv_types = { 'out_invoice': 'CI', 'in_invoice': 'SI', 'out_refund': 'OR', 'in_refund': 'SR', } for l in res: @@ -224,6 +237,8 @@ class general_ledger(report_sxw.rml_parse, common_report_header): l['amount_currency'] = abs(l['amount_currency']) * -1 if l['amount_currency'] != None: self.tot_currency = self.tot_currency + l['amount_currency'] + self.cr.execute("select distinct currency_id from account_invoice") + l['cur_id']=self.cr.fetchall() return res def _sum_debit_account(self, account): diff --git a/addons/account/report/account_general_ledger.rml b/addons/account/report/account_general_ledger.rml index feeaa1fa18c..d91b9bbca5c 100644 --- a/addons/account/report/account_general_ledger.rml +++ b/addons/account/report/account_general_ledger.rml @@ -340,7 +340,7 @@ [[formatLang(sum_debit_account(o)) ]] [[formatLang(sum_credit_account(o)) ]] [[formatLang(sum_balance_account(o)) ]] [[ company.currency_id.symbol ]] - [[ (o.currency_id and formatLang(sum_currency_amount_account(o))) or removeParentNode('font') ]] [[ o.currency_id.symbol or '']] + [[ o.currency_id and sum_currency_amount_account(o) +o.currency_id.symbol or '' ]] @@ -362,7 +362,7 @@ [[ formatLang(line['debit']) ]] [[ formatLang(line['credit']) ]] [[ formatLang(line['progress']) ]] [[ company.currency_id.symbol ]] - [[ (line.has_key('currency_id') and line['currency_id']==None or line['amount_currency']==None) and removeParentNode('font') ]] [[ formatLang(line['amount_currency'])]] [[ line['currency_code'] or '']] + [[ (len(line['cur_id'])==1 and o.currency_id.id==line['currency_id'] and formatLang(line['amount_currency'])) or removeParentNode('font') ]] [[ line['currency_code'] or '']] diff --git a/addons/account/report/account_general_ledger_landscape.rml b/addons/account/report/account_general_ledger_landscape.rml index e91bedb4a5d..6c6da958deb 100644 --- a/addons/account/report/account_general_ledger_landscape.rml +++ b/addons/account/report/account_general_ledger_landscape.rml @@ -327,7 +327,8 @@ [[ formatLang(line['debit'], digits=get_digits(dp='Account')) ]] [[ formatLang(line['credit'], digits=get_digits(dp='Account')) ]] [[ formatLang(line['progress'], digits=get_digits(dp='Account')) ]] [[ company.currency_id.symbol ]] - [[ (o.currency_id and formatLang(line['amount_currency'])) or removeParentNode('font') ]] [[ line['currency_code'] or '']] + + [[ (len(line['cur_id'])==1 and o.currency_id.id==line['currency_id'] and formatLang(line['amount_currency'])) or removeParentNode('font') ]] [[ line['currency_code'] or '']] From 11d9e19f3c172034f381dbd85dc47bddc5ca5c59 Mon Sep 17 00:00:00 2001 From: pso Date: Wed, 24 Nov 2010 14:00:29 +0530 Subject: [PATCH 6/7] [IMP] account: Improved partner ledger report for currency bzr revid: pso@tinyerp.com-20101124083029-kn69p6roavd6786c --- addons/account/report/account_partner_ledger.py | 5 +++++ addons/account/report/account_partner_ledger_other.rml | 8 +++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/addons/account/report/account_partner_ledger.py b/addons/account/report/account_partner_ledger.py index 01b46ae70bc..9958058bf7c 100644 --- a/addons/account/report/account_partner_ledger.py +++ b/addons/account/report/account_partner_ledger.py @@ -51,6 +51,7 @@ class third_party_ledger(report_sxw.rml_parse, common_report_header): 'display_initial_balance':self._display_initial_balance, 'display_currency':self._display_currency, 'get_target_move': self._get_target_move, + 'get_currency': self._get_currency, 'sum_currency_amount_account': self._sum_currency_amount_account }) @@ -162,6 +163,10 @@ class third_party_ledger(report_sxw.rml_parse, common_report_header): full_account.append(r) return full_account + def _get_currency(self): + self.cr.execute("select distinct currency_id from account_invoice") + return self.cr.fetchall() + def _get_intial_balance(self, partner): move_state = ['draft','posted'] if self.target_move == 'posted': diff --git a/addons/account/report/account_partner_ledger_other.rml b/addons/account/report/account_partner_ledger_other.rml index 36aadc9e0dc..be217dd3312 100644 --- a/addons/account/report/account_partner_ledger_other.rml +++ b/addons/account/report/account_partner_ledger_other.rml @@ -638,9 +638,7 @@ [[ formatLang((sum_debit_partner(p) - sum_credit_partner(p))) ]] [[ company.currency_id.symbol ]] - - - + [[ p.property_account_receivable.currency_id and formatLang(sum_currency_amount_account(p.property_account_receivable), digits=get_digits(dp='Account')) + p.property_account_receivable.currency_id.symbol or '' ]] @@ -657,7 +655,7 @@ [[ formatLang(get_intial_balance(p)[0][2]) ]] [[ company.currency_id.symbol ]] - [[ p.property_account_receivable.currency_id and formatLang(sum_currency_amount_account(p.property_account_receivable), digits=get_digits(dp='Account')) + p.property_account_receivable.currency_id.symbol or '' ]] + [[ len(get_currency())==1 and p.property_account_receivable.currency_id and formatLang(sum_currency_amount_account(p.property_account_receivable), digits=get_digits(dp='Account')) + p.property_account_receivable.currency_id.symbol or '' ]] @@ -690,7 +688,7 @@ [[ formatLang((line['progress'])) ]] [[ company.currency_id.symbol ]] - [[ (p.property_account_receivable.currency_id and formatLang(line['amount_currency'])) or removeParentNode('font') ]] [[ line['currency_code'] or '']] + [[ (len(get_currency())==1 and p.property_account_receivable.currency_id and formatLang(line['amount_currency'])) or removeParentNode('font') ]] [[ line['currency_code'] or '']] From a52db24969d1fc89a7dcb2309f58fa7510190d93 Mon Sep 17 00:00:00 2001 From: pso Date: Tue, 7 Dec 2010 10:47:37 +0530 Subject: [PATCH 7/7] [IMP] account, account_voucher: Improved views bzr revid: pso@tinyerp.com-20101207051737-odudndy612vemlgd --- addons/account/account_invoice_view.xml | 7 ++++--- addons/account/account_report.xml | 3 ++- addons/account_voucher/voucher_sales_purchase_view.xml | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index c6542758952..eb375256417 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -302,7 +302,7 @@ - +