From eb1fc58eb88fee927f7f5b5b421a5f776e13d517 Mon Sep 17 00:00:00 2001 From: "Dhara (OpenERP)" <> Date: Tue, 20 Sep 2011 18:35:11 -0700 Subject: [PATCH 1/6] Balance sign field for accouting report bzr revid: dhara_openerp-20110921013511-05czzq3ggdv9197f --- addons/account/account.py | 2 +- addons/account/account_view.xml | 1 + addons/account/report/account_balance_sheet.py | 2 +- .../account/report/account_financial_report.py | 2 +- addons/account/report/account_profit_loss.py | 16 ++++++++++++---- addons/account/report/account_profit_loss.rml | 8 ++++---- 6 files changed, 20 insertions(+), 11 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 61e1fb021a9..a3748e8a167 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -139,7 +139,7 @@ class account_account_type(osv.osv): 'Balance' will generally be used for cash accounts. 'Detail' will copy each existing journal item of the previous year, even the reconciled ones. 'Unreconciled' will copy only the journal items that were unreconciled on the first day of the new fiscal year."""), - 'sign': fields.selection([(-1, 'Negative'), (1, 'Positive')], 'Sign on Reports', required=True, help='Allows you to change the sign of the balance amount displayed in the reports, so that you can see positive figures instead of negative ones in expenses accounts.'), + 'sign': fields.selection([(-1, 'Reverse balance sign'), (1, 'Preserve balance sign')], 'Sign on Reports', required=True, help='For accounts that are typically more debited than credited and that you would like to print as negative amounts in your reports, you should reverse the sign of the balance; e.g.: Expense account. The same applies for accounts that are typically more credited than debited and that you would like to print as positive amounts in your reports; e.g.: Income account.'), 'report_type':fields.selection([ ('none','/'), ('income','Profit & Loss (Income Accounts)'), diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 1055a4a164a..c6e1c58557d 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -749,6 +749,7 @@ + diff --git a/addons/account/report/account_balance_sheet.py b/addons/account/report/account_balance_sheet.py index b1e51e6fc46..ce9e3c51f06 100644 --- a/addons/account/report/account_balance_sheet.py +++ b/addons/account/report/account_balance_sheet.py @@ -136,7 +136,7 @@ class report_balancesheet_horizontal(report_sxw.rml_parse, common_report_header) 'code': account.code, 'name': account.name, 'level': account.level, - 'balance':account.balance, + 'balance': account.balance != 0 and account.balance * account.user_type.sign or account.balance, 'type': account.type, } currency = account.currency_id and account.currency_id or account.company_id.currency_id diff --git a/addons/account/report/account_financial_report.py b/addons/account/report/account_financial_report.py index 6b0ada74708..87b7fab7b8d 100644 --- a/addons/account/report/account_financial_report.py +++ b/addons/account/report/account_financial_report.py @@ -70,7 +70,7 @@ class report_account_common(report_sxw.rml_parse, common_report_header): flag = False vals = { 'name': account.code + ' ' + account.name, - 'balance': account.balance, + 'balance': account.balance != 0 and account.balance * account.user_type.sign or account.balance, 'type': 'account', 'level': 6, 'account_type': account.type, diff --git a/addons/account/report/account_profit_loss.py b/addons/account/report/account_profit_loss.py index 4c8896ee630..27182cdbd21 100644 --- a/addons/account/report/account_profit_loss.py +++ b/addons/account/report/account_profit_loss.py @@ -141,11 +141,15 @@ class report_pl_account_horizontal(report_sxw.rml_parse, common_report_header): 'code': cal_list['expense'][i].code, 'name': cal_list['expense'][i].name, 'level': cal_list['expense'][i].level, - 'balance':cal_list['expense'][i].balance, + 'balance': cal_list['expense'][i].balance != 0 and \ + cal_list['expense'][i].balance * cal_list['expense'][i].user_type.sign or \ + cal_list['expense'][i].balance, 'code1': cal_list['income'][i].code, 'name1': cal_list['income'][i].name, 'level1': cal_list['income'][i].level, - 'balance1':cal_list['income'][i].balance, + 'balance1': cal_list['income'][i].balance != 0 and \ + cal_list['income'][i].balance * cal_list['income'][i].user_type.sign or \ + cal_list['income'][i].balance, } self.result_temp.append(temp) else: @@ -158,7 +162,9 @@ class report_pl_account_horizontal(report_sxw.rml_parse, common_report_header): 'code1': cal_list['income'][i].code, 'name1': cal_list['income'][i].name, 'level1': cal_list['income'][i].level, - 'balance1':cal_list['income'][i].balance, + 'balance1': cal_list['income'][i].balance != 0 and \ + cal_list['income'][i].balance * cal_list['income'][i].user_type.sign \ + or cal_list['income'][i].balance, } self.result_temp.append(temp) if i < len(cal_list['expense']): @@ -166,7 +172,9 @@ class report_pl_account_horizontal(report_sxw.rml_parse, common_report_header): 'code': cal_list['expense'][i].code, 'name': cal_list['expense'][i].name, 'level': cal_list['expense'][i].level, - 'balance':cal_list['expense'][i].balance, + 'balance': cal_list['expense'][i].balance != 0 and \ + cal_list['expense'][i].balance * cal_list['expense'][i].user_type.sign \ + or cal_list['expense'][i].balance, 'code1': '', 'name1': '', 'level1': False, diff --git a/addons/account/report/account_profit_loss.rml b/addons/account/report/account_profit_loss.rml index f0c549e7412..0679e65f4ba 100644 --- a/addons/account/report/account_profit_loss.rml +++ b/addons/account/report/account_profit_loss.rml @@ -228,8 +228,8 @@ [[ setTag('tr','tr',{'style': 'Table'+str(min(3,a.level))}) ]] [[ (a.type =='view' and a.level >= 3) and setTag('para','para',{'style': 'terp_level_3_code_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a.level))+'_code'}) ]][[ a.code ]] [[ (a.type =='view' and a.level >= 3) and setTag('para','para',{'style': 'terp_level_'+str(min(3,a.level))+'_name_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(4,a.level))+'_name'}) ]][[ a.name ]] - [[ (a.level <>2) or removeParentNode('td') ]][[ (a.type =='view' and a.level >= 3) and setTag('para','para',{'style': 'terp_level_3_balance_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a.level))+'_balance'}) ]][[ formatLang(a.balance) ]] [[company.currency_id.symbol ]] - [[ a.level == 2 or removeParentNode('td') ]][[ formatLang(a.balance) ]] [[company.currency_id.symbol ]] + [[ (a.level <>2) or removeParentNode('td') ]][[ (a.type =='view' and a.level >= 3) and setTag('para','para',{'style': 'terp_level_3_balance_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a.level))+'_balance'}) ]][[ formatLang(a.balance * a.user_type.sign) ]] [[company.currency_id.symbol ]] + [[ a.level == 2 or removeParentNode('td') ]][[ formatLang(a.balance * a.user_type.sign) ]] [[company.currency_id.symbol ]] @@ -277,8 +277,8 @@ [[ setTag('tr','tr',{'style': 'Table'+str(min(3,a.level))}) ]] [[ (a.type =='view' and a.level >= 3) and setTag('para','para',{'style': 'terp_level_3_code_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a.level))+'_code'}) ]][[ a.code ]] [[ (a.type =='view' and a.level >= 3) and setTag('para','para',{'style': 'terp_level_'+str(min(3,a.level))+'_name_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(4,a.level))+'_name'}) ]][[ a.name ]] - [[ (a.level <>2) or removeParentNode('td') ]][[ (a.type =='view' and a.level >= 3) and setTag('para','para',{'style': 'terp_level_3_balance_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a.level))+'_balance'}) ]][[ formatLang(a.balance) ]] [[company.currency_id.symbol ]] - [[ a.level == 2 or removeParentNode('td') ]][[ formatLang(a.balance) ]] [[company.currency_id.symbol ]] + [[ (a.level <>2) or removeParentNode('td') ]][[ (a.type =='view' and a.level >= 3) and setTag('para','para',{'style': 'terp_level_3_balance_bold'}) or setTag('para','para',{'style': 'terp_level_'+str(min(3,a.level))+'_balance'}) ]][[ formatLang(a.balance * a.user_type.sign) ]] [[company.currency_id.symbol ]] + [[ a.level == 2 or removeParentNode('td') ]][[ formatLang(a.balance * a.user_type.sign) ]] [[company.currency_id.symbol ]] From b83b56164ff14db4c9767eb5586d8732f41590a1 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Wed, 21 Sep 2011 16:57:58 +0200 Subject: [PATCH 2/6] [IMP] account financial report add type account_type bzr revid: al@openerp.com-20110921145758-zhq3klyfbgzfbeu8 --- addons/account/account.py | 24 ++++++++++++++++-------- addons/account/account_view.xml | 31 +++++++++++++++++++++---------- 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 61e1fb021a9..dffaed6cb0b 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2637,6 +2637,10 @@ class account_fiscal_position_account_template(osv.osv): account_fiscal_position_account_template() +# --------------------------------------------------------- +# Account Financial Report +# --------------------------------------------------------- + class account_financial_report(osv.osv): _name = "account.financial.report" _description = "Account Report" @@ -2691,17 +2695,19 @@ class account_financial_report(osv.osv): 'parent_id': fields.many2one('account.financial.report', 'Parent'), 'children_ids': fields.one2many('account.financial.report', 'parent_id', 'Account Report'), 'sequence': fields.integer('Sequence'), + 'note': fields.text('Notes'), + 'balance': fields.function(_get_balance, 'Balance'), + 'level': fields.function(_get_level, string='Level', store=True, type='integer'), 'type': fields.selection([ - ('sum','Sum'), + ('sum','View'), ('accounts','Accounts'), - ('account_report','Account Report'), + ('account_type','Account Type'), + ('account_report','Report Value'), ],'Type'), 'account_ids': fields.many2many('account.account', 'account_account_financial_report', 'report_line_id', 'account_id', 'Accounts'), - 'note': fields.text('Notes'), - 'account_report_id': fields.many2one('account.financial.report', 'Account Report'), - 'balance': fields.function(_get_balance, 'Balance'), - 'display_detail': fields.boolean('Display the account list'), - 'level': fields.function(_get_level, string='Level', store=True, type='integer'), + 'display_detail': fields.boolean('Display details', help='Display every account with its balance instead of the sum.'), + 'account_report_id': fields.many2one('account.financial.report', 'Report Value'), + 'account_type_id': fields.many2one('account.account.type', 'Account Type'), } _defaults = { @@ -2710,7 +2716,9 @@ class account_financial_report(osv.osv): account_financial_report() - # Multi charts of Accounts wizard +# --------------------------------------------------------- +# Account generation from template wizards +# --------------------------------------------------------- class wizard_multi_charts_accounts(osv.osv_memory): """ diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 1055a4a164a..e3ef40c8402 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -2713,16 +2713,27 @@ action = pool.get('res.config').next(cr, uid, [], context) form
- - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + From 46b4b667e0a9e8f0e97dbdca5ae244f611a2233e Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Wed, 21 Sep 2011 17:07:08 +0200 Subject: [PATCH 3/6] [IMP] account financial type account_type is now m2m bzr revid: al@openerp.com-20110921150708-wkxt83pulih57o93 --- addons/account/account.py | 2 +- addons/account/account_view.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index dffaed6cb0b..3be3bfe2d13 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -2707,7 +2707,7 @@ class account_financial_report(osv.osv): 'account_ids': fields.many2many('account.account', 'account_account_financial_report', 'report_line_id', 'account_id', 'Accounts'), 'display_detail': fields.boolean('Display details', help='Display every account with its balance instead of the sum.'), 'account_report_id': fields.many2one('account.financial.report', 'Report Value'), - 'account_type_id': fields.many2one('account.account.type', 'Account Type'), + 'account_type_ids': fields.many2many('account.account.type', 'account_account_financial_report_type', 'report_id', 'account_type_id', 'Account Types'), } _defaults = { diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index e3ef40c8402..033c98a57f5 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -2727,7 +2727,7 @@ action = pool.get('res.config').next(cr, uid, [], context) - + From f18c91c9a1ceea65cf6ce8d698d5bd62b3fe54cf Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Thu, 22 Sep 2011 01:53:24 +0200 Subject: [PATCH 4/6] [IMP] account.financial.report account_type mode bzr revid: al@openerp.com-20110921235324-fgo9v1g3omppe3h1 --- addons/account/report/account_financial_report.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/account/report/account_financial_report.py b/addons/account/report/account_financial_report.py index 87b7fab7b8d..3a73930f526 100644 --- a/addons/account/report/account_financial_report.py +++ b/addons/account/report/account_financial_report.py @@ -63,8 +63,14 @@ class report_account_common(report_sxw.rml_parse, common_report_header): if data['form']['enable_filter']: vals['balance_cmp'] = self.pool.get('account.financial.report').browse(self.cr, self.uid, report.id, context=data['form']['comparison_context']).balance lines.append(vals) + account_ids = [] if report.type == 'accounts' and report.display_detail and report.account_ids: account_ids = account_obj._get_children_and_consol(self.cr, self.uid, [x.id for x in report.account_ids]) + elif report.type == 'account_type' and report.account_type_ids: + print "accout type" + account_ids = account_obj.search(self.cr, self.uid, [('user_type','in', [x.id for x in report.account_type_ids])]) + print account_ids + if account_ids: for account in account_obj.browse(self.cr, self.uid, account_ids, context=data['form']['used_context']): if account.type != 'view': flag = False From 9a0c6ce1a0850364edf33354e3548e900ddd3098 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Thu, 22 Sep 2011 01:58:03 +0200 Subject: [PATCH 5/6] [IMP] account.financial.report account_type mode remove debug bzr revid: al@openerp.com-20110921235803-p5fcdtsf0m7e6eci --- addons/account/report/account_financial_report.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/addons/account/report/account_financial_report.py b/addons/account/report/account_financial_report.py index 3a73930f526..6b42bb1875d 100644 --- a/addons/account/report/account_financial_report.py +++ b/addons/account/report/account_financial_report.py @@ -67,9 +67,7 @@ class report_account_common(report_sxw.rml_parse, common_report_header): if report.type == 'accounts' and report.display_detail and report.account_ids: account_ids = account_obj._get_children_and_consol(self.cr, self.uid, [x.id for x in report.account_ids]) elif report.type == 'account_type' and report.account_type_ids: - print "accout type" account_ids = account_obj.search(self.cr, self.uid, [('user_type','in', [x.id for x in report.account_type_ids])]) - print account_ids if account_ids: for account in account_obj.browse(self.cr, self.uid, account_ids, context=data['form']['used_context']): if account.type != 'view': From b845e523cafe388595cceabef95d11e90de9a1ea Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Thu, 22 Sep 2011 02:13:01 +0200 Subject: [PATCH 6/6] [IMP] more consistent naming bzr revid: al@openerp.com-20110922001301-75782ppl28nv213e --- addons/account/account_view.xml | 4 ++-- addons/account/wizard/account_financial_report_view.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 7f23f77a3ff..b22274f4546 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -2775,7 +2775,7 @@ action = pool.get('res.config').next(cr, uid, [], context) - Account Reports + Financial Reports ir.actions.act_window account.financial.report form @@ -2802,7 +2802,7 @@ action = pool.get('res.config').next(cr, uid, [], context) - Account Reports Hierarchy + Financial Reports Hierarchy account.financial.report tree diff --git a/addons/account/wizard/account_financial_report_view.xml b/addons/account/wizard/account_financial_report_view.xml index 2083fd0ed53..1472da4ba87 100644 --- a/addons/account/wizard/account_financial_report_view.xml +++ b/addons/account/wizard/account_financial_report_view.xml @@ -31,7 +31,7 @@ - Financial Report + Financial Reports accounting.report ir.actions.act_window form