From 44974a36152f2c4c65e4b5db684c41acf1fe29c1 Mon Sep 17 00:00:00 2001 From: pso Date: Mon, 27 Dec 2010 10:55:13 +0530 Subject: [PATCH 1/3] [IMP] account: put company as selection in entries analysis report bzr revid: pso@tinyerp.com-20101227052513-c88j2kf11683sgj8 --- addons/account/report/account_entries_report_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/report/account_entries_report_view.xml b/addons/account/report/account_entries_report_view.xml index 8eefe75838f..576b62470e6 100644 --- a/addons/account/report/account_entries_report_view.xml +++ b/addons/account/report/account_entries_report_view.xml @@ -94,7 +94,7 @@ - + From 09a2c9d1f105394912096e3432e7282b4ca39c02 Mon Sep 17 00:00:00 2001 From: pso Date: Mon, 27 Dec 2010 12:01:29 +0530 Subject: [PATCH 2/3] [IMP] account: Improved general and partner ledger reports bzr revid: pso@tinyerp.com-20101227063129-u063vl1nst5rg4c7 --- .../account/report/account_general_ledger.py | 23 +++++++++++++++---- .../account/report/account_general_ledger.rml | 2 +- .../account_general_ledger_landscape.rml | 4 ++-- .../account/report/account_partner_ledger.py | 17 +++++++------- .../report/account_partner_ledger_other.rml | 12 +++++++--- 5 files changed, 39 insertions(+), 19 deletions(-) diff --git a/addons/account/report/account_general_ledger.py b/addons/account/report/account_general_ledger.py index b904aba298f..0dd4e354625 100644 --- a/addons/account/report/account_general_ledger.py +++ b/addons/account/report/account_general_ledger.py @@ -159,13 +159,19 @@ class general_ledger(report_sxw.rml_parse, common_report_header): else: sql_sort='l.date, l.move_id' 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,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,per.code as period_code, + case when a.currency_id is not null then + l.amount_currency + else + 0.0 + end as amount_currency, 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) @@ -179,19 +185,26 @@ 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, + SELECT 0 AS lid, '' AS ldate, '' AS lcode, '' 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 period_code, - '' AS currency_code, - NULL AS currency_id, + sum(case when a.currency_id is not null then + l.amount_currency + else + 0.0 + end) as amount_currency, + c.symbol AS currency_code, + 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 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, l.currency_id """ %(self.init_query, tuple(move_state)) self.cr.execute(sql, (account.id,)) res_init = self.cr.dictfetchall() @@ -209,6 +222,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 d3da592e085..e0359249657 100644 --- a/addons/account/report/account_general_ledger.rml +++ b/addons/account/report/account_general_ledger.rml @@ -518,7 +518,7 @@ [[ 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 '']] + [[ (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 56624256300..6892a1fd4bd 100644 --- a/addons/account/report/account_general_ledger_landscape.rml +++ b/addons/account/report/account_general_ledger_landscape.rml @@ -508,7 +508,7 @@ [[ 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 '' ]] @@ -550,7 +550,7 @@ [[ 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 '']] + [[ (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_partner_ledger.py b/addons/account/report/account_partner_ledger.py index 92d84e05c26..554b12aecfc 100644 --- a/addons/account/report/account_partner_ledger.py +++ b/addons/account/report/account_partner_ledger.py @@ -37,6 +37,7 @@ class third_party_ledger(report_sxw.rml_parse, common_report_header): # 'sum_debit': self._sum_debit, # 'sum_credit': self._sum_credit, 'get_currency': self._get_currency, + 'sum_currency_amount_account': self._sum_currency_amount_account, 'comma_me': self.comma_me, 'get_start_period': self.get_start_period, 'get_end_period': self.get_end_period, @@ -160,6 +161,10 @@ class third_party_ledger(report_sxw.rml_parse, common_report_header): r['progress'] = sum 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'] @@ -390,16 +395,10 @@ 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 _sum_currency_amount_account(self, account): + 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 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 b3dec993cdb..b6d4b216bbb 100644 --- a/addons/account/report/account_partner_ledger_other.rml +++ b/addons/account/report/account_partner_ledger_other.rml @@ -470,7 +470,7 @@ [[ display_currency(data) == False or removeParentNode('section') ]] - + [[ p.ref ]] - [[ p.name ]] @@ -484,13 +484,16 @@ [[ 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 '' ]] +
[[data['form']['initial_balance']==True or removeParentNode('section') ]] - + Initial Balance @@ -504,6 +507,9 @@ [[ formatLang(get_intial_balance(p)[0][2]) ]] [[ company.currency_id.symbol ]] + + [[ 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 '' ]] +
@@ -653,7 +659,7 @@ - [[ (line['currency_id']==None or line['amount_currency']==None) and removeParentNode('font') ]] [[ formatLang(line['amount_currency'] ) ]] [[ 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 53b327827b9dd02d3762ae3b9bf1deb8bf9ac543 Mon Sep 17 00:00:00 2001 From: pso Date: Mon, 27 Dec 2010 16:14:32 +0530 Subject: [PATCH 3/3] [FIX] point_of_sale: Set product income acc for credit lp bug: https://launchpad.net/bugs/694107 fixed bzr revid: pso@tinyerp.com-20101227104432-c86phvftbo1l0bx7 --- addons/point_of_sale/point_of_sale.py | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index c75a1aee4d5..0476fb03b31 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -647,7 +647,6 @@ class pos_order(osv.osv): line.qty, partner_id = order.partner_id.id, fposition_id=order.partner_id.property_account_position.id)['value']) inv_line['price_unit'] = line.price_unit inv_line['discount'] = line.discount - inv_line['account_id'] = acc inv_line['name'] = inv_name inv_line['invoice_line_tax_id'] = ('invoice_line_tax_id' in inv_line)\ and [(6, 0, inv_line['invoice_line_tax_id'])] or []