From 81a1cb167fa90d017947511aac950aaad9e1dcc5 Mon Sep 17 00:00:00 2001 From: Yanina Aular Date: Tue, 18 Jun 2013 15:29:44 -0530 Subject: [PATCH 01/35] [ADD] filter for account not in view and consolidated --- account_financial_report/report/parser.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index ea9f8e85..5dcacf17 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -432,6 +432,9 @@ class account_balance(report_sxw.rml_parse): result_acc = [] tot = {} + account_ids_x = account_obj.search(self.cr , self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','not in',('view','consolidation'))])) + print account_ids_x + for aa_id in account_ids: id = aa_id[0] From 313e5d801c6c919c8db7a4fa9a6e1ddef07b1d9d Mon Sep 17 00:00:00 2001 From: Yanina Aular Date: Wed, 19 Jun 2013 09:22:17 -0530 Subject: [PATCH 02/35] [ADD] time and ordered list of account --- account_financial_report/report/parser.py | 28 +++++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index 5dcacf17..6b3e68a9 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -347,7 +347,7 @@ class account_balance(report_sxw.rml_parse): ################################################################ # Get the accounts # ################################################################ - + start_time = time.clock() account_ids = _get_children_and_consol(self.cr, self.uid, account_ids, form[ 'display_account_level'] and form['display_account_level'] or 100, self.context) @@ -359,7 +359,7 @@ class account_balance(report_sxw.rml_parse): credit_account_ids = list(set( credit_account_ids) - set(debit_account_ids)) - + print time.clock() - start_time, "seconds" # # Generate the report lines (checking each account) # @@ -432,8 +432,25 @@ class account_balance(report_sxw.rml_parse): result_acc = [] tot = {} - account_ids_x = account_obj.search(self.cr , self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','not in',('view','consolidation'))])) - print account_ids_x + account_ids_black = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','not in',('view','consolidation'))])) + account_ids_black = account_obj.browse(self.cr, self.uid, account_ids_black) + + account_ids_not_black = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','in',('view','consolidation'))])) + account_ids_not_black = account_obj.browse(self.cr, self.uid, account_ids_not_black) + account_ids_not_black.sort(key=lambda x: x.level) + account_ids_not_black.reverse() + + print "Negros" + for i in account_ids_black: + print i.name + print i.level + + print "No Negros" + for i in account_ids_not_black: + print i.name + print i.level + + start_time = time.clock() for aa_id in account_ids: id = aa_id[0] @@ -707,7 +724,8 @@ class account_balance(report_sxw.rml_parse): tot_crd += res['credit'] tot_ytd += res['ytd'] tot_eje += res['balance'] - + print time.clock() - start_time, "seconds" + if tot_check: str_label = form['lab_str'] res2 = { From fa81a67363e966cbe36b8bf7cc731fed98752055 Mon Sep 17 00:00:00 2001 From: Yanina Aular Date: Wed, 19 Jun 2013 09:37:05 -0530 Subject: [PATCH 03/35] [ADD] ready list of account --- account_financial_report/report/parser.py | 32 +++++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index 6b3e68a9..c2f72d09 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -434,22 +434,44 @@ class account_balance(report_sxw.rml_parse): account_ids_black = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','not in',('view','consolidation'))])) account_ids_black = account_obj.browse(self.cr, self.uid, account_ids_black) + account_ids_black.sort(key=lambda x: x.level) + account_ids_black.reverse() account_ids_not_black = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','in',('view','consolidation'))])) account_ids_not_black = account_obj.browse(self.cr, self.uid, account_ids_not_black) account_ids_not_black.sort(key=lambda x: x.level) account_ids_not_black.reverse() + + black = [] print "Negros" for i in account_ids_black: - print i.name - print i.level + black_data = {} + black_data['obj'] = i + black_data['debit'] = i.debit + black_data['credit'] = i.credit + black_data['balance'] = i.balance + black_data['parent_id'] = i.parent_id + #print i.name + #print i.level + #print black_data + black.append(black_data) + not_black = [] print "No Negros" for i in account_ids_not_black: - print i.name - print i.level - + not_black_data = {} + not_black_data['obj'] = i + not_black_data['debit'] = i.debit + not_black_data['credit'] = i.credit + not_black_data['balance'] = i.balance + not_black_data['parent_id'] = i.parent_id + #print i.name + #print i.level + not_black.append(not_black_data) + + #import pdb + #pdb.set_trace() start_time = time.clock() for aa_id in account_ids: From b5388db66b2bf947681931d2eb0cafa8f8b0e00d Mon Sep 17 00:00:00 2001 From: Yanina Aular Date: Wed, 19 Jun 2013 10:11:57 -0530 Subject: [PATCH 04/35] [ADD] accounts dict ready --- account_financial_report/report/parser.py | 48 +++++++++++++++-------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index c2f72d09..8ffb8721 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -432,34 +432,39 @@ class account_balance(report_sxw.rml_parse): result_acc = [] tot = {} - account_ids_black = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','not in',('view','consolidation'))])) - account_ids_black = account_obj.browse(self.cr, self.uid, account_ids_black) - account_ids_black.sort(key=lambda x: x.level) - account_ids_black.reverse() + ############################################################### + # + # + ############################################################### - account_ids_not_black = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','in',('view','consolidation'))])) - account_ids_not_black = account_obj.browse(self.cr, self.uid, account_ids_not_black) - account_ids_not_black.sort(key=lambda x: x.level) - account_ids_not_black.reverse() + account_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','not in',('view','consolidation'))])) + account_black = account_obj.browse(self.cr, self.uid, account_black_ids) + account_black.sort(key=lambda x: x.level) + account_black.reverse() + + account_not_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','in',('view','consolidation'))])) + account_not_black = account_obj.browse(self.cr, self.uid, account_not_black_ids) + account_not_black.sort(key=lambda x: x.level) + account_not_black.reverse() - black = [] + dict_black = {} print "Negros" - for i in account_ids_black: + for i in account_black: black_data = {} black_data['obj'] = i black_data['debit'] = i.debit black_data['credit'] = i.credit black_data['balance'] = i.balance black_data['parent_id'] = i.parent_id - #print i.name + print i.id, i.name #print i.level #print black_data - black.append(black_data) + dict_black[i.id] = black_data - not_black = [] + dict_not_black = {} print "No Negros" - for i in account_ids_not_black: + for i in account_not_black: not_black_data = {} not_black_data['obj'] = i not_black_data['debit'] = i.debit @@ -468,10 +473,21 @@ class account_balance(report_sxw.rml_parse): not_black_data['parent_id'] = i.parent_id #print i.name #print i.level - not_black.append(not_black_data) - + dict_not_black[i.id] = not_black_data + + + for i in dict_not_black: + print dict_not_black[i].get('obj').name + print dict_not_black[i].get('obj')._get_child_ids(self.cr, self.uid) + #import pdb #pdb.set_trace() + + ############################################################### + # + # + ############################################################### + start_time = time.clock() for aa_id in account_ids: From 6089a30ad955cd37a0bc7d5cae51663b8e7b487e Mon Sep 17 00:00:00 2001 From: Yanina Aular Date: Wed, 19 Jun 2013 11:17:26 -0530 Subject: [PATCH 05/35] [ADD] sum of accounts view and consolidated --- account_financial_report/report/parser.py | 38 ++++++++++++++++------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index 8ffb8721..a71407ef 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -432,21 +432,25 @@ class account_balance(report_sxw.rml_parse): result_acc = [] tot = {} + start_time = time.clock() ############################################################### # # ############################################################### + form['periods'] = [0] + ctx_init = _ctx_init(self.context.copy()) account_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','not in',('view','consolidation'))])) - account_black = account_obj.browse(self.cr, self.uid, account_black_ids) + account_black = account_obj.browse(self.cr, self.uid, account_black_ids, ctx_init) account_black.sort(key=lambda x: x.level) account_black.reverse() + account_black_ids = [i.id for i in account_black] account_not_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','in',('view','consolidation'))])) - account_not_black = account_obj.browse(self.cr, self.uid, account_not_black_ids) + account_not_black = account_obj.browse(self.cr, self.uid, account_not_black_ids, ctx_init) account_not_black.sort(key=lambda x: x.level) account_not_black.reverse() - + account_not_black_ids = [i.id for i in account_not_black] dict_black = {} print "Negros" @@ -467,22 +471,34 @@ class account_balance(report_sxw.rml_parse): for i in account_not_black: not_black_data = {} not_black_data['obj'] = i - not_black_data['debit'] = i.debit - not_black_data['credit'] = i.credit - not_black_data['balance'] = i.balance + not_black_data['debit'] = 0.0 + not_black_data['credit'] = 0.0 + not_black_data['balance'] = 0.0 not_black_data['parent_id'] = i.parent_id - #print i.name - #print i.level dict_not_black[i.id] = not_black_data - + all_account = dict_black.copy() #se hace una copia, porque se modificara + + print "##################" for i in dict_not_black: - print dict_not_black[i].get('obj').name - print dict_not_black[i].get('obj')._get_child_ids(self.cr, self.uid) + print dict_not_black[i].get('obj').name , dict_not_black[i].get('debit') + for acc_id in account_not_black_ids: + print dict_not_black[acc_id].get('obj').name + acc_childs = dict_not_black[acc_id].get('obj')._get_child_ids(self.cr, self.uid).popitem()[1] #hijos de la cuenta i (id) + for child_id in acc_childs: + dict_not_black[acc_id]['debit'] += all_account[child_id].get('debit') + all_account[acc_id] = dict_not_black[acc_id] + + print "##################" + for i in all_account: + print all_account[i].get('obj').name , all_account[i].get('debit') + #import pdb #pdb.set_trace() + print time.clock() - start_time, "seconds" + # ############################################################### # # From d900f6611f0be4320c376e4a80a97dc5050392f5 Mon Sep 17 00:00:00 2001 From: Yanina Aular Date: Wed, 19 Jun 2013 12:19:36 -0530 Subject: [PATCH 06/35] [ADD] account values per period --- account_financial_report/report/parser.py | 110 +++++++++++----------- 1 file changed, 57 insertions(+), 53 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index a71407ef..a73814e0 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -35,6 +35,7 @@ from report import report_sxw from tools import config from tools.translate import _ from osv import osv +import pdb class account_balance(report_sxw.rml_parse): @@ -437,62 +438,65 @@ class account_balance(report_sxw.rml_parse): # # ############################################################### - form['periods'] = [0] - ctx_init = _ctx_init(self.context.copy()) + pdb.set_trace() + print period_ids + for p_id in period_ids: + form['periods'] = [p_id] + ctx_init = _ctx_init(self.context.copy()) - account_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','not in',('view','consolidation'))])) - account_black = account_obj.browse(self.cr, self.uid, account_black_ids, ctx_init) - account_black.sort(key=lambda x: x.level) - account_black.reverse() - account_black_ids = [i.id for i in account_black] + account_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','not in',('view','consolidation'))])) + account_black = account_obj.browse(self.cr, self.uid, account_black_ids, ctx_init) + account_black.sort(key=lambda x: x.level) + account_black.reverse() + account_black_ids = [i.id for i in account_black] - account_not_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','in',('view','consolidation'))])) - account_not_black = account_obj.browse(self.cr, self.uid, account_not_black_ids, ctx_init) - account_not_black.sort(key=lambda x: x.level) - account_not_black.reverse() - account_not_black_ids = [i.id for i in account_not_black] - - dict_black = {} - print "Negros" - for i in account_black: - black_data = {} - black_data['obj'] = i - black_data['debit'] = i.debit - black_data['credit'] = i.credit - black_data['balance'] = i.balance - black_data['parent_id'] = i.parent_id - print i.id, i.name - #print i.level - #print black_data - dict_black[i.id] = black_data - - dict_not_black = {} - print "No Negros" - for i in account_not_black: - not_black_data = {} - not_black_data['obj'] = i - not_black_data['debit'] = 0.0 - not_black_data['credit'] = 0.0 - not_black_data['balance'] = 0.0 - not_black_data['parent_id'] = i.parent_id - dict_not_black[i.id] = not_black_data - - all_account = dict_black.copy() #se hace una copia, porque se modificara - - print "##################" - for i in dict_not_black: - print dict_not_black[i].get('obj').name , dict_not_black[i].get('debit') - - for acc_id in account_not_black_ids: - print dict_not_black[acc_id].get('obj').name - acc_childs = dict_not_black[acc_id].get('obj')._get_child_ids(self.cr, self.uid).popitem()[1] #hijos de la cuenta i (id) - for child_id in acc_childs: - dict_not_black[acc_id]['debit'] += all_account[child_id].get('debit') - all_account[acc_id] = dict_not_black[acc_id] + account_not_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','in',('view','consolidation'))])) + account_not_black = account_obj.browse(self.cr, self.uid, account_not_black_ids, ctx_init) + account_not_black.sort(key=lambda x: x.level) + account_not_black.reverse() + account_not_black_ids = [i.id for i in account_not_black] - print "##################" - for i in all_account: - print all_account[i].get('obj').name , all_account[i].get('debit') + dict_black = {} + print "Negros" + for i in account_black: + black_data = {} + black_data['obj'] = i + black_data['debit'] = i.debit + black_data['credit'] = i.credit + black_data['balance'] = i.balance + black_data['parent_id'] = i.parent_id + print i.id, i.name + #print i.level + #print black_data + dict_black[i.id] = black_data + + dict_not_black = {} + print "No Negros" + for i in account_not_black: + not_black_data = {} + not_black_data['obj'] = i + not_black_data['debit'] = 0.0 + not_black_data['credit'] = 0.0 + not_black_data['balance'] = 0.0 + not_black_data['parent_id'] = i.parent_id + dict_not_black[i.id] = not_black_data + + all_account = dict_black.copy() #se hace una copia, porque se modificara + + print "##################" + for i in dict_not_black: + print dict_not_black[i].get('obj').name , dict_not_black[i].get('debit') + + for acc_id in account_not_black_ids: + print dict_not_black[acc_id].get('obj').name + acc_childs = dict_not_black[acc_id].get('obj')._get_child_ids(self.cr, self.uid).popitem()[1] #hijos de la cuenta i (id) + for child_id in acc_childs: + dict_not_black[acc_id]['debit'] += all_account[child_id].get('debit') + all_account[acc_id] = dict_not_black[acc_id] + + print "##################" + for i in all_account: + print all_account[i].get('obj').name , all_account[i].get('debit') #import pdb #pdb.set_trace() From 45efba42debe4a7fd9fb81d9fd5d0eebe75366f7 Mon Sep 17 00:00:00 2001 From: Yanina Aular Date: Wed, 19 Jun 2013 13:10:26 -0530 Subject: [PATCH 07/35] [IMP] deleted attr parent_id, added coditional for context init or context end --- account_financial_report/report/parser.py | 29 ++++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index a73814e0..cf7d89c7 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -442,44 +442,45 @@ class account_balance(report_sxw.rml_parse): print period_ids for p_id in period_ids: form['periods'] = [p_id] - ctx_init = _ctx_init(self.context.copy()) + + if form['inf_type'] == 'IS': + ctx_to_use = _ctx_end(self.context.copy()) + else: + ctx_to_use = _ctx_init(self.context.copy()) account_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','not in',('view','consolidation'))])) - account_black = account_obj.browse(self.cr, self.uid, account_black_ids, ctx_init) - account_black.sort(key=lambda x: x.level) - account_black.reverse() - account_black_ids = [i.id for i in account_black] + account_black = account_obj.browse(self.cr, self.uid, account_black_ids, ctx_to_use) + #account_black.sort(key=lambda x: x.level) + #account_black.reverse() + #account_black_ids = [i.id for i in account_black] account_not_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','in',('view','consolidation'))])) - account_not_black = account_obj.browse(self.cr, self.uid, account_not_black_ids, ctx_init) + account_not_black = account_obj.browse(self.cr, self.uid, account_not_black_ids, ctx_to_use) account_not_black.sort(key=lambda x: x.level) account_not_black.reverse() account_not_black_ids = [i.id for i in account_not_black] + #~ Negros dict_black = {} - print "Negros" for i in account_black: black_data = {} black_data['obj'] = i black_data['debit'] = i.debit black_data['credit'] = i.credit black_data['balance'] = i.balance - black_data['parent_id'] = i.parent_id - print i.id, i.name - #print i.level - #print black_data dict_black[i.id] = black_data - + ######################### + + #~ No negros dict_not_black = {} - print "No Negros" for i in account_not_black: not_black_data = {} not_black_data['obj'] = i not_black_data['debit'] = 0.0 not_black_data['credit'] = 0.0 not_black_data['balance'] = 0.0 - not_black_data['parent_id'] = i.parent_id dict_not_black[i.id] = not_black_data + ########################### all_account = dict_black.copy() #se hace una copia, porque se modificara From ac0ea3826be4f3035871c73731b63f69311cba7d Mon Sep 17 00:00:00 2001 From: Yanina Aular Date: Wed, 19 Jun 2013 13:11:28 -0530 Subject: [PATCH 08/35] [IMP] deleted attr parent_id, added coditional for context init or context end and not order for black account --- account_financial_report/report/parser.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index cf7d89c7..ee939c8b 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -450,9 +450,6 @@ class account_balance(report_sxw.rml_parse): account_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','not in',('view','consolidation'))])) account_black = account_obj.browse(self.cr, self.uid, account_black_ids, ctx_to_use) - #account_black.sort(key=lambda x: x.level) - #account_black.reverse() - #account_black_ids = [i.id for i in account_black] account_not_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','in',('view','consolidation'))])) account_not_black = account_obj.browse(self.cr, self.uid, account_not_black_ids, ctx_to_use) From d9097c96b1196ef3a1d6c69538730c52a82f4cce Mon Sep 17 00:00:00 2001 From: Yanina Aular Date: Wed, 19 Jun 2013 14:37:09 -0530 Subject: [PATCH 09/35] [IMP] sum with saved fields --- account_financial_report/report/parser.py | 95 ++++++++++------------- 1 file changed, 42 insertions(+), 53 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index ee939c8b..da7b461a 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -438,19 +438,28 @@ class account_balance(report_sxw.rml_parse): # # ############################################################### - pdb.set_trace() - print period_ids - for p_id in period_ids: - form['periods'] = [p_id] + + all_account_period = {} #todas las cuentas por periodo + + for p_act in range(0,13): + + if p_act == 12: + form['periods'] = period_ids + else: + form['periods'] = [period_ids[p_act]] if form['inf_type'] == 'IS': ctx_to_use = _ctx_end(self.context.copy()) else: + ctx_i = _ctx_init(self.context.copy()) ctx_to_use = _ctx_init(self.context.copy()) + account_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','not in',('view','consolidation'))])) account_black = account_obj.browse(self.cr, self.uid, account_black_ids, ctx_to_use) + account_black_init = account_obj.browse(self.cr, self.uid, account_black_ids, ctx_i) + account_not_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','in',('view','consolidation'))])) account_not_black = account_obj.browse(self.cr, self.uid, account_not_black_ids, ctx_to_use) account_not_black.sort(key=lambda x: x.level) @@ -465,9 +474,15 @@ class account_balance(report_sxw.rml_parse): black_data['debit'] = i.debit black_data['credit'] = i.credit black_data['balance'] = i.balance + black_data['balanceinit'] = 0.0 dict_black[i.id] = black_data + + for i in account_black_init: + dict_black[i.id]['balanceinit'] = i.balance ######################### + + #~ No negros dict_not_black = {} for i in account_not_black: @@ -476,6 +491,7 @@ class account_balance(report_sxw.rml_parse): not_black_data['debit'] = 0.0 not_black_data['credit'] = 0.0 not_black_data['balance'] = 0.0 + not_black_data['balanceinit'] = 0.0 dict_not_black[i.id] = not_black_data ########################### @@ -490,15 +506,24 @@ class account_balance(report_sxw.rml_parse): acc_childs = dict_not_black[acc_id].get('obj')._get_child_ids(self.cr, self.uid).popitem()[1] #hijos de la cuenta i (id) for child_id in acc_childs: dict_not_black[acc_id]['debit'] += all_account[child_id].get('debit') + dict_not_black[acc_id]['credit'] += all_account[child_id].get('credit') + dict_not_black[acc_id]['balance'] += all_account[child_id].get('balance') + dict_not_black[acc_id]['balanceinit'] += all_account[child_id].get('balanceinit') all_account[acc_id] = dict_not_black[acc_id] print "##################" for i in all_account: print all_account[i].get('obj').name , all_account[i].get('debit') + + if p_act == 12: + all_account_period['all'] = all_account + else: + all_account_period[ period_ids[p_act] ] = all_account - #import pdb - #pdb.set_trace() - + + + + print all_account_period print time.clock() - start_time, "seconds" # ############################################################### @@ -530,19 +555,10 @@ class account_balance(report_sxw.rml_parse): if form['columns'] == 'qtr': pn = 1 for p_id in p: - form['periods'] = p_id - - ctx_init = _ctx_init(self.context.copy()) - aa_brw_init = account_obj.browse( - self.cr, self.uid, id, ctx_init) - - ctx_end = _ctx_end(self.context.copy()) - aa_brw_end = account_obj.browse( - self.cr, self.uid, id, ctx_end) if form['inf_type'] == 'IS': d, c, b = map(z, [ - aa_brw_end.debit, aa_brw_end.credit, aa_brw_end.balance]) + all_account_period[p_id].get(id).get('debit'), all_account_period[p_id].get(id).get('credit'), all_account_period[p_id].get(id).get('balance')]) res.update({ 'dbr%s' % pn: self.exchange(d), 'cdr%s' % pn: self.exchange(c), @@ -550,7 +566,7 @@ class account_balance(report_sxw.rml_parse): }) else: i, d, c = map(z, [ - aa_brw_init.balance, aa_brw_end.debit, aa_brw_end.credit]) + all_account_period[p_id].get(id).get('balanceinit'), all_account_period[p_id].get(id).get('debit'), all_account_period[p_id].get(id).get('credit')]) b = z(i+d-c) res.update({ 'dbr%s' % pn: self.exchange(d), @@ -560,19 +576,9 @@ class account_balance(report_sxw.rml_parse): pn += 1 - form['periods'] = period_ids - - ctx_init = _ctx_init(self.context.copy()) - aa_brw_init = account_obj.browse( - self.cr, self.uid, id, ctx_init) - - ctx_end = _ctx_end(self.context.copy()) - aa_brw_end = account_obj.browse( - self.cr, self.uid, id, ctx_end) - if form['inf_type'] == 'IS': d, c, b = map(z, [ - aa_brw_end.debit, aa_brw_end.credit, aa_brw_end.balance]) + all_account_period['all'].get(id).get('debit', 0.0), all_account_period['all'].get(id).get('credit', 0.0), all_account_period['all'].get(id).get('balance', 0.0)]) res.update({ 'dbr5': self.exchange(d), 'cdr5': self.exchange(c), @@ -580,7 +586,7 @@ class account_balance(report_sxw.rml_parse): }) else: i, d, c = map(z, [ - aa_brw_init.balance, aa_brw_end.debit, aa_brw_end.credit]) + all_account_period['all'].get(id).get('balanceinit', 0.0), all_account_period['all'].get(id).get('debit', 0.0), all_account_period['all'].get(id).get('credit', 0.0)]) b = z(i+d-c) res.update({ 'dbr5': self.exchange(d), @@ -591,19 +597,10 @@ class account_balance(report_sxw.rml_parse): elif form['columns'] == 'thirteen': pn = 1 for p_id in period_ids: - form['periods'] = [p_id] - - ctx_init = _ctx_init(self.context.copy()) - aa_brw_init = account_obj.browse( - self.cr, self.uid, id, ctx_init) - - ctx_end = _ctx_end(self.context.copy()) - aa_brw_end = account_obj.browse( - self.cr, self.uid, id, ctx_end) if form['inf_type'] == 'IS': d, c, b = map(z, [ - aa_brw_end.debit, aa_brw_end.credit, aa_brw_end.balance]) + all_account_period[p_id].get(id).get('debit', 0.0), all_account_period[p_id].get(id).get('credit', 0.0), all_account_period[p_id].get(id).get('balance', 0.0)]) res.update({ 'dbr%s' % pn: self.exchange(d), 'cdr%s' % pn: self.exchange(c), @@ -611,29 +608,21 @@ class account_balance(report_sxw.rml_parse): }) else: i, d, c = map(z, [ - aa_brw_init.balance, aa_brw_end.debit, aa_brw_end.credit]) + all_account_period[p_id].get(id).get('balanceinit', 0.0), all_account_period[p_id].get(id).get('debit', 0.0), all_account_period[p_id].get(id).get('credit', 0.0)]) b = z(i+d-c) res.update({ 'dbr%s' % pn: self.exchange(d), 'cdr%s' % pn: self.exchange(c), 'bal%s' % pn: self.exchange(b), }) + print p_id + print all_account_period[p_id].get(id).get('debit'), all_account_period[p_id].get(id).get('credit'), all_account_period[p_id].get(id).get('balance') pn += 1 - form['periods'] = period_ids - - ctx_init = _ctx_init(self.context.copy()) - aa_brw_init = account_obj.browse( - self.cr, self.uid, id, ctx_init) - - ctx_end = _ctx_end(self.context.copy()) - aa_brw_end = account_obj.browse( - self.cr, self.uid, id, ctx_end) - if form['inf_type'] == 'IS': d, c, b = map(z, [ - aa_brw_end.debit, aa_brw_end.credit, aa_brw_end.balance]) + all_account_period['all'].get(id).get('debit', 0.0), all_account_period['all'].get(id).get('credit', 0.0), all_account_period['all'].get(id).get('balance', 0.0)]) res.update({ 'dbr13': self.exchange(d), 'cdr13': self.exchange(c), @@ -641,7 +630,7 @@ class account_balance(report_sxw.rml_parse): }) else: i, d, c = map(z, [ - aa_brw_init.balance, aa_brw_end.debit, aa_brw_end.credit]) + all_account_period['all'].get(id).get('balanceinit', 0.0), all_account_period['all'].get(id).get('debit', 0.0), all_account_period['all'].get(id).get('credit', 0.0)]) b = z(i+d-c) res.update({ 'dbr13': self.exchange(d), From 7fae216c6c5477b268ae95aa2d78ee10116679ca Mon Sep 17 00:00:00 2001 From: Yanina Aular Date: Wed, 19 Jun 2013 15:48:25 -0530 Subject: [PATCH 10/35] [IMP] Ignore balanceinit when the report type is statement of income --- account_financial_report/report/parser.py | 39 +++++++++++++++-------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index da7b461a..5b2a6f50 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -458,7 +458,8 @@ class account_balance(report_sxw.rml_parse): account_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','not in',('view','consolidation'))])) account_black = account_obj.browse(self.cr, self.uid, account_black_ids, ctx_to_use) - account_black_init = account_obj.browse(self.cr, self.uid, account_black_ids, ctx_i) + if form['inf_type'] == 'BF': + account_black_init = account_obj.browse(self.cr, self.uid, account_black_ids, ctx_i) account_not_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','in',('view','consolidation'))])) account_not_black = account_obj.browse(self.cr, self.uid, account_not_black_ids, ctx_to_use) @@ -474,11 +475,13 @@ class account_balance(report_sxw.rml_parse): black_data['debit'] = i.debit black_data['credit'] = i.credit black_data['balance'] = i.balance - black_data['balanceinit'] = 0.0 + if form['inf_type'] == 'BF': + black_data['balanceinit'] = 0.0 dict_black[i.id] = black_data - for i in account_black_init: - dict_black[i.id]['balanceinit'] = i.balance + if form['inf_type'] == 'BF': + for i in account_black_init: + dict_black[i.id]['balanceinit'] = i.balance ######################### @@ -491,7 +494,8 @@ class account_balance(report_sxw.rml_parse): not_black_data['debit'] = 0.0 not_black_data['credit'] = 0.0 not_black_data['balance'] = 0.0 - not_black_data['balanceinit'] = 0.0 + if form['inf_type'] == 'BF': + not_black_data['balanceinit'] = 0.0 dict_not_black[i.id] = not_black_data ########################### @@ -503,27 +507,36 @@ class account_balance(report_sxw.rml_parse): for acc_id in account_not_black_ids: print dict_not_black[acc_id].get('obj').name - acc_childs = dict_not_black[acc_id].get('obj')._get_child_ids(self.cr, self.uid).popitem()[1] #hijos de la cuenta i (id) + acc_childs = dict_not_black[acc_id].get('obj').child_id for child_id in acc_childs: - dict_not_black[acc_id]['debit'] += all_account[child_id].get('debit') - dict_not_black[acc_id]['credit'] += all_account[child_id].get('credit') - dict_not_black[acc_id]['balance'] += all_account[child_id].get('balance') - dict_not_black[acc_id]['balanceinit'] += all_account[child_id].get('balanceinit') + dict_not_black[acc_id]['debit'] += all_account[child_id.id].get('debit') + dict_not_black[acc_id]['credit'] += all_account[child_id.id].get('credit') + dict_not_black[acc_id]['balance'] += all_account[child_id.id].get('balance') + if form['inf_type'] == 'BF': + dict_not_black[acc_id]['balanceinit'] += all_account[child_id.id].get('balanceinit') all_account[acc_id] = dict_not_black[acc_id] print "##################" for i in all_account: print all_account[i].get('obj').name , all_account[i].get('debit') - if p_act == 12: all_account_period['all'] = all_account else: all_account_period[ period_ids[p_act] ] = all_account + #pdb.set_trace() + #print "periodo 1 #######################" + #for i in all_account_period.get(1): + # j = all_account_period.get(1).get(i) + # print j.get('obj').name , j.get('debit') - - print all_account_period + #print "periodo 2 #######################" + #for i in all_account_period.get(2): + # j = all_account_period.get(2).get(i) + # print j.get('obj').name , j.get('debit') + + #print all_account_period print time.clock() - start_time, "seconds" # ############################################################### From 50c8471a6a22f7469c4a526a23e82467aa150dff Mon Sep 17 00:00:00 2001 From: Yanina Aular Date: Wed, 19 Jun 2013 16:28:07 -0530 Subject: [PATCH 11/35] [IMP] calculations just 12 columns --- account_financial_report/report/parser.py | 158 +++++++++++----------- 1 file changed, 79 insertions(+), 79 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index 5b2a6f50..8c3865c6 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -440,89 +440,89 @@ class account_balance(report_sxw.rml_parse): ############################################################### all_account_period = {} #todas las cuentas por periodo - - for p_act in range(0,13): + if form['columns'] == 'thirteen': + for p_act in range(0,13): - if p_act == 12: - form['periods'] = period_ids - else: - form['periods'] = [period_ids[p_act]] + if p_act == 12: + form['periods'] = period_ids + else: + form['periods'] = [period_ids[p_act]] - if form['inf_type'] == 'IS': - ctx_to_use = _ctx_end(self.context.copy()) - else: - ctx_i = _ctx_init(self.context.copy()) - ctx_to_use = _ctx_init(self.context.copy()) + if form['inf_type'] == 'IS': + ctx_to_use = _ctx_end(self.context.copy()) + else: + ctx_i = _ctx_init(self.context.copy()) + ctx_to_use = _ctx_init(self.context.copy()) - - account_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','not in',('view','consolidation'))])) - account_black = account_obj.browse(self.cr, self.uid, account_black_ids, ctx_to_use) - - if form['inf_type'] == 'BF': - account_black_init = account_obj.browse(self.cr, self.uid, account_black_ids, ctx_i) - - account_not_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','in',('view','consolidation'))])) - account_not_black = account_obj.browse(self.cr, self.uid, account_not_black_ids, ctx_to_use) - account_not_black.sort(key=lambda x: x.level) - account_not_black.reverse() - account_not_black_ids = [i.id for i in account_not_black] - - #~ Negros - dict_black = {} - for i in account_black: - black_data = {} - black_data['obj'] = i - black_data['debit'] = i.debit - black_data['credit'] = i.credit - black_data['balance'] = i.balance - if form['inf_type'] == 'BF': - black_data['balanceinit'] = 0.0 - dict_black[i.id] = black_data - - if form['inf_type'] == 'BF': - for i in account_black_init: - dict_black[i.id]['balanceinit'] = i.balance - ######################### - - - - #~ No negros - dict_not_black = {} - for i in account_not_black: - not_black_data = {} - not_black_data['obj'] = i - not_black_data['debit'] = 0.0 - not_black_data['credit'] = 0.0 - not_black_data['balance'] = 0.0 - if form['inf_type'] == 'BF': - not_black_data['balanceinit'] = 0.0 - dict_not_black[i.id] = not_black_data - ########################### - - all_account = dict_black.copy() #se hace una copia, porque se modificara - - print "##################" - for i in dict_not_black: - print dict_not_black[i].get('obj').name , dict_not_black[i].get('debit') - - for acc_id in account_not_black_ids: - print dict_not_black[acc_id].get('obj').name - acc_childs = dict_not_black[acc_id].get('obj').child_id - for child_id in acc_childs: - dict_not_black[acc_id]['debit'] += all_account[child_id.id].get('debit') - dict_not_black[acc_id]['credit'] += all_account[child_id.id].get('credit') - dict_not_black[acc_id]['balance'] += all_account[child_id.id].get('balance') - if form['inf_type'] == 'BF': - dict_not_black[acc_id]['balanceinit'] += all_account[child_id.id].get('balanceinit') - all_account[acc_id] = dict_not_black[acc_id] - print "##################" - for i in all_account: - print all_account[i].get('obj').name , all_account[i].get('debit') - if p_act == 12: - all_account_period['all'] = all_account - else: - all_account_period[ period_ids[p_act] ] = all_account + account_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','not in',('view','consolidation'))])) + account_black = account_obj.browse(self.cr, self.uid, account_black_ids, ctx_to_use) + + if form['inf_type'] == 'BF': + account_black_init = account_obj.browse(self.cr, self.uid, account_black_ids, ctx_i) + + account_not_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','in',('view','consolidation'))])) + account_not_black = account_obj.browse(self.cr, self.uid, account_not_black_ids, ctx_to_use) + account_not_black.sort(key=lambda x: x.level) + account_not_black.reverse() + account_not_black_ids = [i.id for i in account_not_black] + + #~ Negros + dict_black = {} + for i in account_black: + black_data = {} + black_data['obj'] = i + black_data['debit'] = i.debit + black_data['credit'] = i.credit + black_data['balance'] = i.balance + if form['inf_type'] == 'BF': + black_data['balanceinit'] = 0.0 + dict_black[i.id] = black_data + + if form['inf_type'] == 'BF': + for i in account_black_init: + dict_black[i.id]['balanceinit'] = i.balance + ######################### + + + + #~ No negros + dict_not_black = {} + for i in account_not_black: + not_black_data = {} + not_black_data['obj'] = i + not_black_data['debit'] = 0.0 + not_black_data['credit'] = 0.0 + not_black_data['balance'] = 0.0 + if form['inf_type'] == 'BF': + not_black_data['balanceinit'] = 0.0 + dict_not_black[i.id] = not_black_data + ########################### + + all_account = dict_black.copy() #se hace una copia, porque se modificara + + print "##################" + for i in dict_not_black: + print dict_not_black[i].get('obj').name , dict_not_black[i].get('debit') + + for acc_id in account_not_black_ids: + print dict_not_black[acc_id].get('obj').name + acc_childs = dict_not_black[acc_id].get('obj').child_id + for child_id in acc_childs: + dict_not_black[acc_id]['debit'] += all_account[child_id.id].get('debit') + dict_not_black[acc_id]['credit'] += all_account[child_id.id].get('credit') + dict_not_black[acc_id]['balance'] += all_account[child_id.id].get('balance') + if form['inf_type'] == 'BF': + dict_not_black[acc_id]['balanceinit'] += all_account[child_id.id].get('balanceinit') + all_account[acc_id] = dict_not_black[acc_id] + + print "##################" + for i in all_account: + print all_account[i].get('obj').name , all_account[i].get('debit') + if p_act == 12: + all_account_period['all'] = all_account + else: + all_account_period[ period_ids[p_act] ] = all_account #pdb.set_trace() From d610e788c5f3f41374d26174df9a6e6c351ddef2 Mon Sep 17 00:00:00 2001 From: Yanina Aular Date: Wed, 19 Jun 2013 16:40:32 -0530 Subject: [PATCH 12/35] [CC] pep8 to parser.py --- account_financial_report/report/parser.py | 88 ++++++++++++----------- 1 file changed, 46 insertions(+), 42 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index 8c3865c6..2c5813aa 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -433,15 +433,15 @@ class account_balance(report_sxw.rml_parse): result_acc = [] tot = {} - start_time = time.clock() + start_time = time.clock() ############################################################### - # + # calculos optimos # ############################################################### - - all_account_period = {} #todas las cuentas por periodo - if form['columns'] == 'thirteen': - for p_act in range(0,13): + + all_account_period = {} # todas las cuentas por periodo + if form['columns'] == 'thirteen': + for p_act in range(0, 13): if p_act == 12: form['periods'] = period_ids @@ -454,19 +454,23 @@ class account_balance(report_sxw.rml_parse): ctx_i = _ctx_init(self.context.copy()) ctx_to_use = _ctx_init(self.context.copy()) - - account_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','not in',('view','consolidation'))])) - account_black = account_obj.browse(self.cr, self.uid, account_black_ids, ctx_to_use) + account_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[ + 0] for i in account_ids]), ('type', 'not in', ('view', 'consolidation'))])) + account_black = account_obj.browse( + self.cr, self.uid, account_black_ids, ctx_to_use) if form['inf_type'] == 'BF': - account_black_init = account_obj.browse(self.cr, self.uid, account_black_ids, ctx_i) + account_black_init = account_obj.browse( + self.cr, self.uid, account_black_ids, ctx_i) - account_not_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[0] for i in account_ids]),('type','in',('view','consolidation'))])) - account_not_black = account_obj.browse(self.cr, self.uid, account_not_black_ids, ctx_to_use) + account_not_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [ + i[0] for i in account_ids]), ('type', 'in', ('view', 'consolidation'))])) + account_not_black = account_obj.browse( + self.cr, self.uid, account_not_black_ids, ctx_to_use) account_not_black.sort(key=lambda x: x.level) account_not_black.reverse() account_not_black_ids = [i.id for i in account_not_black] - + #~ Negros dict_black = {} for i in account_black: @@ -478,14 +482,12 @@ class account_balance(report_sxw.rml_parse): if form['inf_type'] == 'BF': black_data['balanceinit'] = 0.0 dict_black[i.id] = black_data - + if form['inf_type'] == 'BF': for i in account_black_init: dict_black[i.id]['balanceinit'] = i.balance ######################### - - #~ No negros dict_not_black = {} for i in account_not_black: @@ -498,53 +500,55 @@ class account_balance(report_sxw.rml_parse): not_black_data['balanceinit'] = 0.0 dict_not_black[i.id] = not_black_data ########################### - - all_account = dict_black.copy() #se hace una copia, porque se modificara - + + all_account = dict_black.copy( + ) # se hace una copia, porque se modificara + print "##################" for i in dict_not_black: - print dict_not_black[i].get('obj').name , dict_not_black[i].get('debit') + print dict_not_black[i].get('obj').name, dict_not_black[i].get('debit') for acc_id in account_not_black_ids: print dict_not_black[acc_id].get('obj').name acc_childs = dict_not_black[acc_id].get('obj').child_id for child_id in acc_childs: - dict_not_black[acc_id]['debit'] += all_account[child_id.id].get('debit') - dict_not_black[acc_id]['credit'] += all_account[child_id.id].get('credit') - dict_not_black[acc_id]['balance'] += all_account[child_id.id].get('balance') + dict_not_black[acc_id]['debit'] += all_account[ + child_id.id].get('debit') + dict_not_black[acc_id]['credit'] += all_account[ + child_id.id].get('credit') + dict_not_black[acc_id]['balance'] += all_account[ + child_id.id].get('balance') if form['inf_type'] == 'BF': - dict_not_black[acc_id]['balanceinit'] += all_account[child_id.id].get('balanceinit') + dict_not_black[acc_id]['balanceinit'] += all_account[ + child_id.id].get('balanceinit') all_account[acc_id] = dict_not_black[acc_id] - + print "##################" for i in all_account: - print all_account[i].get('obj').name , all_account[i].get('debit') + print all_account[i].get('obj').name, all_account[i].get('debit') if p_act == 12: all_account_period['all'] = all_account else: - all_account_period[ period_ids[p_act] ] = all_account - + all_account_period[period_ids[p_act]] = all_account - #pdb.set_trace() - #print "periodo 1 #######################" - #for i in all_account_period.get(1): + # pdb.set_trace() + # print "periodo 1 #######################" + # for i in all_account_period.get(1): # j = all_account_period.get(1).get(i) # print j.get('obj').name , j.get('debit') - - #print "periodo 2 #######################" - #for i in all_account_period.get(2): + # print "periodo 2 #######################" + # for i in all_account_period.get(2): # j = all_account_period.get(2).get(i) # print j.get('obj').name , j.get('debit') - - #print all_account_period + # print all_account_period print time.clock() - start_time, "seconds" # ############################################################### - # + # Fin de calculos optimos, sumatoria de valores # ############################################################### - - start_time = time.clock() + + start_time = time.clock() for aa_id in account_ids: id = aa_id[0] @@ -613,7 +617,7 @@ class account_balance(report_sxw.rml_parse): if form['inf_type'] == 'IS': d, c, b = map(z, [ - all_account_period[p_id].get(id).get('debit', 0.0), all_account_period[p_id].get(id).get('credit', 0.0), all_account_period[p_id].get(id).get('balance', 0.0)]) + all_account_period[p_id].get(id).get('debit', 0.0), all_account_period[p_id].get(id).get('credit', 0.0), all_account_period[p_id].get(id).get('balance', 0.0)]) res.update({ 'dbr%s' % pn: self.exchange(d), 'cdr%s' % pn: self.exchange(c), @@ -621,7 +625,7 @@ class account_balance(report_sxw.rml_parse): }) else: i, d, c = map(z, [ - all_account_period[p_id].get(id).get('balanceinit', 0.0), all_account_period[p_id].get(id).get('debit', 0.0), all_account_period[p_id].get(id).get('credit', 0.0)]) + all_account_period[p_id].get(id).get('balanceinit', 0.0), all_account_period[p_id].get(id).get('debit', 0.0), all_account_period[p_id].get(id).get('credit', 0.0)]) b = z(i+d-c) res.update({ 'dbr%s' % pn: self.exchange(d), @@ -783,7 +787,7 @@ class account_balance(report_sxw.rml_parse): tot_ytd += res['ytd'] tot_eje += res['balance'] print time.clock() - start_time, "seconds" - + if tot_check: str_label = form['lab_str'] res2 = { From 8fb2a5591d1581209e43b8eb37bd4863e4929205 Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Wed, 19 Jun 2013 17:15:02 -0530 Subject: [PATCH 13/35] [FIX] Wrong type: BF, right is BS --- account_financial_report/report/parser.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index 2c5813aa..9f413faa 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -459,7 +459,7 @@ class account_balance(report_sxw.rml_parse): account_black = account_obj.browse( self.cr, self.uid, account_black_ids, ctx_to_use) - if form['inf_type'] == 'BF': + if form['inf_type'] == 'BS': account_black_init = account_obj.browse( self.cr, self.uid, account_black_ids, ctx_i) @@ -479,11 +479,11 @@ class account_balance(report_sxw.rml_parse): black_data['debit'] = i.debit black_data['credit'] = i.credit black_data['balance'] = i.balance - if form['inf_type'] == 'BF': + if form['inf_type'] == 'BS': black_data['balanceinit'] = 0.0 dict_black[i.id] = black_data - if form['inf_type'] == 'BF': + if form['inf_type'] == 'BS': for i in account_black_init: dict_black[i.id]['balanceinit'] = i.balance ######################### @@ -496,7 +496,7 @@ class account_balance(report_sxw.rml_parse): not_black_data['debit'] = 0.0 not_black_data['credit'] = 0.0 not_black_data['balance'] = 0.0 - if form['inf_type'] == 'BF': + if form['inf_type'] == 'BS': not_black_data['balanceinit'] = 0.0 dict_not_black[i.id] = not_black_data ########################### @@ -518,7 +518,7 @@ class account_balance(report_sxw.rml_parse): child_id.id].get('credit') dict_not_black[acc_id]['balance'] += all_account[ child_id.id].get('balance') - if form['inf_type'] == 'BF': + if form['inf_type'] == 'BS': dict_not_black[acc_id]['balanceinit'] += all_account[ child_id.id].get('balanceinit') all_account[acc_id] = dict_not_black[acc_id] From c53093a1702e5291157828d3cad4ba0fb3398b4e Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Wed, 19 Jun 2013 17:23:33 -0530 Subject: [PATCH 14/35] [IMP] All accounts are for all reports --- account_financial_report/report/parser.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index 9f413faa..3377b899 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -439,6 +439,10 @@ class account_balance(report_sxw.rml_parse): # ############################################################### + account_black_ids = account_obj.search(self.cr, self.uid, ( + [('id', 'in', [i[0] for i in account_ids]), + ('type', 'not in', + ('view', 'consolidation'))])) all_account_period = {} # todas las cuentas por periodo if form['columns'] == 'thirteen': for p_act in range(0, 13): @@ -454,8 +458,6 @@ class account_balance(report_sxw.rml_parse): ctx_i = _ctx_init(self.context.copy()) ctx_to_use = _ctx_init(self.context.copy()) - account_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [i[ - 0] for i in account_ids]), ('type', 'not in', ('view', 'consolidation'))])) account_black = account_obj.browse( self.cr, self.uid, account_black_ids, ctx_to_use) From 0787f3f0c3ec8099ed652639a2fb530e151d0cf4 Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Wed, 19 Jun 2013 20:14:23 -0530 Subject: [PATCH 15/35] [IMP] All accounts are for all reports --- account_financial_report/report/parser.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index 3377b899..b1d5218f 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -443,6 +443,17 @@ class account_balance(report_sxw.rml_parse): [('id', 'in', [i[0] for i in account_ids]), ('type', 'not in', ('view', 'consolidation'))])) + + account_not_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [ + i[0] for i in account_ids]), ('type', 'in', ('view', 'consolidation'))])) + + #This could be done quickly with a sql sentence + account_not_black = account_obj.browse( + self.cr, self.uid, account_not_black_ids, ctx_to_use) + account_not_black.sort(key=lambda x: x.level) + account_not_black.reverse() + account_not_black_ids = [i.id for i in account_not_black] + all_account_period = {} # todas las cuentas por periodo if form['columns'] == 'thirteen': for p_act in range(0, 13): @@ -465,14 +476,6 @@ class account_balance(report_sxw.rml_parse): account_black_init = account_obj.browse( self.cr, self.uid, account_black_ids, ctx_i) - account_not_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [ - i[0] for i in account_ids]), ('type', 'in', ('view', 'consolidation'))])) - account_not_black = account_obj.browse( - self.cr, self.uid, account_not_black_ids, ctx_to_use) - account_not_black.sort(key=lambda x: x.level) - account_not_black.reverse() - account_not_black_ids = [i.id for i in account_not_black] - #~ Negros dict_black = {} for i in account_black: From fedd090791177ff0ceed9cfe10a160d3efc88781 Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Wed, 19 Jun 2013 22:07:06 -0530 Subject: [PATCH 16/35] [FIX] Wrong context was being used for Balance Statement --- account_financial_report/report/parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index b1d5218f..1a99bbec 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -449,7 +449,7 @@ class account_balance(report_sxw.rml_parse): #This could be done quickly with a sql sentence account_not_black = account_obj.browse( - self.cr, self.uid, account_not_black_ids, ctx_to_use) + self.cr, self.uid, account_not_black_ids) account_not_black.sort(key=lambda x: x.level) account_not_black.reverse() account_not_black_ids = [i.id for i in account_not_black] @@ -467,7 +467,7 @@ class account_balance(report_sxw.rml_parse): ctx_to_use = _ctx_end(self.context.copy()) else: ctx_i = _ctx_init(self.context.copy()) - ctx_to_use = _ctx_init(self.context.copy()) + ctx_to_use = _ctx_end(self.context.copy()) account_black = account_obj.browse( self.cr, self.uid, account_black_ids, ctx_to_use) From 26491fc7ed4f9f67c2fc528732c9901da11b1c87 Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Wed, 19 Jun 2013 23:37:54 -0530 Subject: [PATCH 17/35] [IMP] We have now QTRs Reports again :-) --- account_financial_report/report/parser.py | 91 +++++++++++++++++++++-- 1 file changed, 85 insertions(+), 6 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index 1a99bbec..15560cf8 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -390,8 +390,6 @@ class account_balance(report_sxw.rml_parse): l = [] a = 0 - #~ period_ids = p - elif form['columns'] == 'thirteen': period_ids = period_obj.search(self.cr, self.uid, [( 'fiscalyear_id', '=', fiscalyear.id), ('special', '=', False)], order='date_start asc') @@ -536,6 +534,87 @@ class account_balance(report_sxw.rml_parse): else: all_account_period[period_ids[p_act]] = all_account + elif form['columns'] == 'qtr': + for p_act in range(5): + + if p_act == 4: + form['periods'] = period_ids + else: + form['periods'] = p[p_act] + + if form['inf_type'] == 'IS': + ctx_to_use = _ctx_end(self.context.copy()) + else: + ctx_i = _ctx_init(self.context.copy()) + ctx_to_use = _ctx_end(self.context.copy()) + + account_black = account_obj.browse( + self.cr, self.uid, account_black_ids, ctx_to_use) + + if form['inf_type'] == 'BS': + account_black_init = account_obj.browse( + self.cr, self.uid, account_black_ids, ctx_i) + + #~ Negros + dict_black = {} + for i in account_black: + black_data = {} + black_data['obj'] = i + black_data['debit'] = i.debit + black_data['credit'] = i.credit + black_data['balance'] = i.balance + if form['inf_type'] == 'BS': + black_data['balanceinit'] = 0.0 + dict_black[i.id] = black_data + + if form['inf_type'] == 'BS': + for i in account_black_init: + dict_black[i.id]['balanceinit'] = i.balance + ######################### + + #~ No negros + dict_not_black = {} + for i in account_not_black: + not_black_data = {} + not_black_data['obj'] = i + not_black_data['debit'] = 0.0 + not_black_data['credit'] = 0.0 + not_black_data['balance'] = 0.0 + if form['inf_type'] == 'BS': + not_black_data['balanceinit'] = 0.0 + dict_not_black[i.id] = not_black_data + ########################### + + all_account = dict_black.copy( + ) # se hace una copia, porque se modificara + + print "##################" + for i in dict_not_black: + print dict_not_black[i].get('obj').name, dict_not_black[i].get('debit') + + for acc_id in account_not_black_ids: + print dict_not_black[acc_id].get('obj').name + acc_childs = dict_not_black[acc_id].get('obj').child_id + for child_id in acc_childs: + dict_not_black[acc_id]['debit'] += all_account[ + child_id.id].get('debit') + dict_not_black[acc_id]['credit'] += all_account[ + child_id.id].get('credit') + dict_not_black[acc_id]['balance'] += all_account[ + child_id.id].get('balance') + if form['inf_type'] == 'BS': + dict_not_black[acc_id]['balanceinit'] += all_account[ + child_id.id].get('balanceinit') + all_account[acc_id] = dict_not_black[acc_id] + + print "##################" + for i in all_account: + print all_account[i].get('obj').name, all_account[i].get('debit') + if p_act == 4: + all_account_period['all'] = all_account + else: + all_account_period[p_act] = all_account + # pdb.set_trace() # print "periodo 1 #######################" # for i in all_account_period.get(1): @@ -580,7 +659,7 @@ class account_balance(report_sxw.rml_parse): if form['inf_type'] == 'IS': d, c, b = map(z, [ - all_account_period[p_id].get(id).get('debit'), all_account_period[p_id].get(id).get('credit'), all_account_period[p_id].get(id).get('balance')]) + all_account_period[pn-1][id]['debit'], all_account_period[pn-1][id]['credit'], all_account_period[pn-1][id]['balance']]) res.update({ 'dbr%s' % pn: self.exchange(d), 'cdr%s' % pn: self.exchange(c), @@ -588,7 +667,7 @@ class account_balance(report_sxw.rml_parse): }) else: i, d, c = map(z, [ - all_account_period[p_id].get(id).get('balanceinit'), all_account_period[p_id].get(id).get('debit'), all_account_period[p_id].get(id).get('credit')]) + all_account_period[pn-1][id]['balanceinit'], all_account_period[pn-1][id]['debit'], all_account_period[pn-1][id]['credit']]) b = z(i+d-c) res.update({ 'dbr%s' % pn: self.exchange(d), @@ -600,7 +679,7 @@ class account_balance(report_sxw.rml_parse): if form['inf_type'] == 'IS': d, c, b = map(z, [ - all_account_period['all'].get(id).get('debit', 0.0), all_account_period['all'].get(id).get('credit', 0.0), all_account_period['all'].get(id).get('balance', 0.0)]) + all_account_period['all'][id]['debit'], all_account_period['all'][id]['credit'], all_account_period['all'][id]['balance']]) res.update({ 'dbr5': self.exchange(d), 'cdr5': self.exchange(c), @@ -608,7 +687,7 @@ class account_balance(report_sxw.rml_parse): }) else: i, d, c = map(z, [ - all_account_period['all'].get(id).get('balanceinit', 0.0), all_account_period['all'].get(id).get('debit', 0.0), all_account_period['all'].get(id).get('credit', 0.0)]) + all_account_period['all'][id]['balanceinit'], all_account_period['all'][id]['debit'], all_account_period['all'][id]['credit']]) b = z(i+d-c) res.update({ 'dbr5': self.exchange(d), From 5948cd59099966ec387b13f430b6cf7bf6e1d9c3 Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Thu, 20 Jun 2013 00:32:51 -0530 Subject: [PATCH 18/35] [IMP] Minor improvements --- account_financial_report/report/parser.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index 15560cf8..3f7e24b9 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -654,8 +654,7 @@ class account_balance(report_sxw.rml_parse): } if form['columns'] == 'qtr': - pn = 1 - for p_id in p: + for pn in range(1,5): if form['inf_type'] == 'IS': d, c, b = map(z, [ @@ -675,8 +674,6 @@ class account_balance(report_sxw.rml_parse): 'bal%s' % pn: self.exchange(b), }) - pn += 1 - if form['inf_type'] == 'IS': d, c, b = map(z, [ all_account_period['all'][id]['debit'], all_account_period['all'][id]['credit'], all_account_period['all'][id]['balance']]) From 7c2aec9627b34cfe3041b2e2306f0bd187fbe879 Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Thu, 20 Jun 2013 01:11:39 -0530 Subject: [PATCH 19/35] [IMP] Now it is possible to print the remaining reports --- account_financial_report/report/parser.py | 73 ++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index 3f7e24b9..c56f15cf 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -615,6 +615,77 @@ class account_balance(report_sxw.rml_parse): else: all_account_period[p_act] = all_account + else: + if form['inf_type'] == 'IS': + ctx_to_use = _ctx_end(self.context.copy()) + else: + ctx_i = _ctx_init(self.context.copy()) + ctx_to_use = _ctx_end(self.context.copy()) + + account_black = account_obj.browse( + self.cr, self.uid, account_black_ids, ctx_to_use) + + if form['inf_type'] == 'BS': + account_black_init = account_obj.browse( + self.cr, self.uid, account_black_ids, ctx_i) + + #~ Negros + dict_black = {} + for i in account_black: + black_data = {} + black_data['obj'] = i + black_data['debit'] = i.debit + black_data['credit'] = i.credit + black_data['balance'] = i.balance + if form['inf_type'] == 'BS': + black_data['balanceinit'] = 0.0 + dict_black[i.id] = black_data + + if form['inf_type'] == 'BS': + for i in account_black_init: + dict_black[i.id]['balanceinit'] = i.balance + ######################### + + #~ No negros + dict_not_black = {} + for i in account_not_black: + not_black_data = {} + not_black_data['obj'] = i + not_black_data['debit'] = 0.0 + not_black_data['credit'] = 0.0 + not_black_data['balance'] = 0.0 + if form['inf_type'] == 'BS': + not_black_data['balanceinit'] = 0.0 + dict_not_black[i.id] = not_black_data + ########################### + + all_account = dict_black.copy( + ) # se hace una copia, porque se modificara + + print "##################" + for i in dict_not_black: + print dict_not_black[i].get('obj').name, dict_not_black[i].get('debit') + + for acc_id in account_not_black_ids: + print dict_not_black[acc_id].get('obj').name + acc_childs = dict_not_black[acc_id].get('obj').child_id + for child_id in acc_childs: + dict_not_black[acc_id]['debit'] += all_account[ + child_id.id].get('debit') + dict_not_black[acc_id]['credit'] += all_account[ + child_id.id].get('credit') + dict_not_black[acc_id]['balance'] += all_account[ + child_id.id].get('balance') + if form['inf_type'] == 'BS': + dict_not_black[acc_id]['balanceinit'] += all_account[ + child_id.id].get('balanceinit') + all_account[acc_id] = dict_not_black[acc_id] + + print "##################" + for i in all_account: + print all_account[i].get('obj').name, all_account[i].get('debit') + all_account_period['all'] = all_account + # pdb.set_trace() # print "periodo 1 #######################" # for i in all_account_period.get(1): @@ -744,7 +815,7 @@ class account_balance(report_sxw.rml_parse): self.cr, self.uid, id, ctx_end) i, d, c = map(z, [ - aa_brw_init.balance, aa_brw_end.debit, aa_brw_end.credit]) + all_account_period['all'][id]['balanceinit'], all_account_period['all'][id]['debit'], all_account_period['all'][id]['credit']]) b = z(i+d-c) res.update({ 'balanceinit': self.exchange(i), From 4a675eaa2b5a4ae277aca477d04a2c547505e893 Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Thu, 20 Jun 2013 01:31:06 -0530 Subject: [PATCH 20/35] [CC] Removing some prints there are some remaining CC stands for Cosmetic Changes --- account_financial_report/report/parser.py | 26 ----------------------- 1 file changed, 26 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index c56f15cf..122e727d 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -507,12 +507,7 @@ class account_balance(report_sxw.rml_parse): all_account = dict_black.copy( ) # se hace una copia, porque se modificara - print "##################" - for i in dict_not_black: - print dict_not_black[i].get('obj').name, dict_not_black[i].get('debit') - for acc_id in account_not_black_ids: - print dict_not_black[acc_id].get('obj').name acc_childs = dict_not_black[acc_id].get('obj').child_id for child_id in acc_childs: dict_not_black[acc_id]['debit'] += all_account[ @@ -526,9 +521,6 @@ class account_balance(report_sxw.rml_parse): child_id.id].get('balanceinit') all_account[acc_id] = dict_not_black[acc_id] - print "##################" - for i in all_account: - print all_account[i].get('obj').name, all_account[i].get('debit') if p_act == 12: all_account_period['all'] = all_account else: @@ -588,12 +580,7 @@ class account_balance(report_sxw.rml_parse): all_account = dict_black.copy( ) # se hace una copia, porque se modificara - print "##################" - for i in dict_not_black: - print dict_not_black[i].get('obj').name, dict_not_black[i].get('debit') - for acc_id in account_not_black_ids: - print dict_not_black[acc_id].get('obj').name acc_childs = dict_not_black[acc_id].get('obj').child_id for child_id in acc_childs: dict_not_black[acc_id]['debit'] += all_account[ @@ -607,9 +594,6 @@ class account_balance(report_sxw.rml_parse): child_id.id].get('balanceinit') all_account[acc_id] = dict_not_black[acc_id] - print "##################" - for i in all_account: - print all_account[i].get('obj').name, all_account[i].get('debit') if p_act == 4: all_account_period['all'] = all_account else: @@ -662,12 +646,7 @@ class account_balance(report_sxw.rml_parse): all_account = dict_black.copy( ) # se hace una copia, porque se modificara - print "##################" - for i in dict_not_black: - print dict_not_black[i].get('obj').name, dict_not_black[i].get('debit') - for acc_id in account_not_black_ids: - print dict_not_black[acc_id].get('obj').name acc_childs = dict_not_black[acc_id].get('obj').child_id for child_id in acc_childs: dict_not_black[acc_id]['debit'] += all_account[ @@ -681,9 +660,6 @@ class account_balance(report_sxw.rml_parse): child_id.id].get('balanceinit') all_account[acc_id] = dict_not_black[acc_id] - print "##################" - for i in all_account: - print all_account[i].get('obj').name, all_account[i].get('debit') all_account_period['all'] = all_account # pdb.set_trace() @@ -784,8 +760,6 @@ class account_balance(report_sxw.rml_parse): 'cdr%s' % pn: self.exchange(c), 'bal%s' % pn: self.exchange(b), }) - print p_id - print all_account_period[p_id].get(id).get('debit'), all_account_period[p_id].get(id).get('credit'), all_account_period[p_id].get(id).get('balance') pn += 1 From bbe09074c896cda631b6460ff74b014457929851 Mon Sep 17 00:00:00 2001 From: Yanina Aular Date: Thu, 20 Jun 2013 08:15:22 -0530 Subject: [PATCH 21/35] [IMP] redundant processes has been simplified one conditional --- account_financial_report/report/parser.py | 99 +++++------------------ 1 file changed, 21 insertions(+), 78 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index 122e727d..8b6343ae 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -453,86 +453,26 @@ class account_balance(report_sxw.rml_parse): account_not_black_ids = [i.id for i in account_not_black] all_account_period = {} # todas las cuentas por periodo + + if form['columns'] == 'thirteen': - for p_act in range(0, 13): - - if p_act == 12: - form['periods'] = period_ids - else: - form['periods'] = [period_ids[p_act]] - - if form['inf_type'] == 'IS': - ctx_to_use = _ctx_end(self.context.copy()) - else: - ctx_i = _ctx_init(self.context.copy()) - ctx_to_use = _ctx_end(self.context.copy()) - - account_black = account_obj.browse( - self.cr, self.uid, account_black_ids, ctx_to_use) - - if form['inf_type'] == 'BS': - account_black_init = account_obj.browse( - self.cr, self.uid, account_black_ids, ctx_i) - - #~ Negros - dict_black = {} - for i in account_black: - black_data = {} - black_data['obj'] = i - black_data['debit'] = i.debit - black_data['credit'] = i.credit - black_data['balance'] = i.balance - if form['inf_type'] == 'BS': - black_data['balanceinit'] = 0.0 - dict_black[i.id] = black_data - - if form['inf_type'] == 'BS': - for i in account_black_init: - dict_black[i.id]['balanceinit'] = i.balance - ######################### - - #~ No negros - dict_not_black = {} - for i in account_not_black: - not_black_data = {} - not_black_data['obj'] = i - not_black_data['debit'] = 0.0 - not_black_data['credit'] = 0.0 - not_black_data['balance'] = 0.0 - if form['inf_type'] == 'BS': - not_black_data['balanceinit'] = 0.0 - dict_not_black[i.id] = not_black_data - ########################### - - all_account = dict_black.copy( - ) # se hace una copia, porque se modificara - - for acc_id in account_not_black_ids: - acc_childs = dict_not_black[acc_id].get('obj').child_id - for child_id in acc_childs: - dict_not_black[acc_id]['debit'] += all_account[ - child_id.id].get('debit') - dict_not_black[acc_id]['credit'] += all_account[ - child_id.id].get('credit') - dict_not_black[acc_id]['balance'] += all_account[ - child_id.id].get('balance') - if form['inf_type'] == 'BS': - dict_not_black[acc_id]['balanceinit'] += all_account[ - child_id.id].get('balanceinit') - all_account[acc_id] = dict_not_black[acc_id] - - if p_act == 12: - all_account_period['all'] = all_account - else: - all_account_period[period_ids[p_act]] = all_account - + limit = 13 + periods_to_use = period_ids elif form['columns'] == 'qtr': - for p_act in range(5): + limit = 5 + periods_to_use = p - if p_act == 4: + + if form['columns'] == 'thirteen' or form['columns'] == 'qtr': + for p_act in range(limit): + + if p_act == limit-1: form['periods'] = period_ids else: - form['periods'] = p[p_act] + if form['columns'] == 'thirteen': + form['periods'] = [period_ids[p_act]] + elif form['columns'] == 'qtr': + form['periods'] = p[p_act] if form['inf_type'] == 'IS': ctx_to_use = _ctx_end(self.context.copy()) @@ -559,6 +499,7 @@ class account_balance(report_sxw.rml_parse): black_data['balanceinit'] = 0.0 dict_black[i.id] = black_data + #Se adicionan los valores de balanceinit al diccionario if form['inf_type'] == 'BS': for i in account_black_init: dict_black[i.id]['balanceinit'] = i.balance @@ -594,11 +535,13 @@ class account_balance(report_sxw.rml_parse): child_id.id].get('balanceinit') all_account[acc_id] = dict_not_black[acc_id] - if p_act == 4: + if p_act == limit-1: all_account_period['all'] = all_account else: - all_account_period[p_act] = all_account - + if form['columns'] == 'thirteen': + all_account_period[period_ids[p_act]] = all_account + elif form['columns'] == 'qtr': + all_account_period[p_act] = all_account else: if form['inf_type'] == 'IS': ctx_to_use = _ctx_end(self.context.copy()) From 4aa6430c941983d7e24609cc19fa836f4b426bcd Mon Sep 17 00:00:00 2001 From: Yanina Aular Date: Thu, 20 Jun 2013 08:43:40 -0530 Subject: [PATCH 22/35] [IMP] redundant processes has been simplified other conditional --- account_financial_report/report/parser.py | 87 ++++------------------- 1 file changed, 12 insertions(+), 75 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index 8b6343ae..cfaec475 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -417,10 +417,8 @@ class account_balance(report_sxw.rml_parse): tot_bal13 = 0.0 else: - ctx_init = _ctx_init(self.context.copy()) ctx_end = _ctx_end(self.context.copy()) - tot_bin = 0.0 tot_deb = 0.0 tot_crd = 0.0 @@ -461,11 +459,12 @@ class account_balance(report_sxw.rml_parse): elif form['columns'] == 'qtr': limit = 5 periods_to_use = p - + else: + limit = 1 - if form['columns'] == 'thirteen' or form['columns'] == 'qtr': - for p_act in range(limit): + for p_act in range(limit): + if limit != 1: if p_act == limit-1: form['periods'] = period_ids else: @@ -474,75 +473,6 @@ class account_balance(report_sxw.rml_parse): elif form['columns'] == 'qtr': form['periods'] = p[p_act] - if form['inf_type'] == 'IS': - ctx_to_use = _ctx_end(self.context.copy()) - else: - ctx_i = _ctx_init(self.context.copy()) - ctx_to_use = _ctx_end(self.context.copy()) - - account_black = account_obj.browse( - self.cr, self.uid, account_black_ids, ctx_to_use) - - if form['inf_type'] == 'BS': - account_black_init = account_obj.browse( - self.cr, self.uid, account_black_ids, ctx_i) - - #~ Negros - dict_black = {} - for i in account_black: - black_data = {} - black_data['obj'] = i - black_data['debit'] = i.debit - black_data['credit'] = i.credit - black_data['balance'] = i.balance - if form['inf_type'] == 'BS': - black_data['balanceinit'] = 0.0 - dict_black[i.id] = black_data - - #Se adicionan los valores de balanceinit al diccionario - if form['inf_type'] == 'BS': - for i in account_black_init: - dict_black[i.id]['balanceinit'] = i.balance - ######################### - - #~ No negros - dict_not_black = {} - for i in account_not_black: - not_black_data = {} - not_black_data['obj'] = i - not_black_data['debit'] = 0.0 - not_black_data['credit'] = 0.0 - not_black_data['balance'] = 0.0 - if form['inf_type'] == 'BS': - not_black_data['balanceinit'] = 0.0 - dict_not_black[i.id] = not_black_data - ########################### - - all_account = dict_black.copy( - ) # se hace una copia, porque se modificara - - for acc_id in account_not_black_ids: - acc_childs = dict_not_black[acc_id].get('obj').child_id - for child_id in acc_childs: - dict_not_black[acc_id]['debit'] += all_account[ - child_id.id].get('debit') - dict_not_black[acc_id]['credit'] += all_account[ - child_id.id].get('credit') - dict_not_black[acc_id]['balance'] += all_account[ - child_id.id].get('balance') - if form['inf_type'] == 'BS': - dict_not_black[acc_id]['balanceinit'] += all_account[ - child_id.id].get('balanceinit') - all_account[acc_id] = dict_not_black[acc_id] - - if p_act == limit-1: - all_account_period['all'] = all_account - else: - if form['columns'] == 'thirteen': - all_account_period[period_ids[p_act]] = all_account - elif form['columns'] == 'qtr': - all_account_period[p_act] = all_account - else: if form['inf_type'] == 'IS': ctx_to_use = _ctx_end(self.context.copy()) else: @@ -568,6 +498,7 @@ class account_balance(report_sxw.rml_parse): black_data['balanceinit'] = 0.0 dict_black[i.id] = black_data + #Se adicionan los valores de balanceinit al diccionario if form['inf_type'] == 'BS': for i in account_black_init: dict_black[i.id]['balanceinit'] = i.balance @@ -603,7 +534,13 @@ class account_balance(report_sxw.rml_parse): child_id.id].get('balanceinit') all_account[acc_id] = dict_not_black[acc_id] - all_account_period['all'] = all_account + if p_act == limit-1: + all_account_period['all'] = all_account + else: + if form['columns'] == 'thirteen': + all_account_period[period_ids[p_act]] = all_account + elif form['columns'] == 'qtr': + all_account_period[p_act] = all_account # pdb.set_trace() # print "periodo 1 #######################" From dea97bd6e0f17256c7f6e5080f634087d0a19df8 Mon Sep 17 00:00:00 2001 From: Yanina Aular Date: Thu, 20 Jun 2013 08:47:53 -0530 Subject: [PATCH 23/35] [CC] cleaning commets and performance calculation --- account_financial_report/report/parser.py | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index cfaec475..e5b85591 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -348,7 +348,6 @@ class account_balance(report_sxw.rml_parse): ################################################################ # Get the accounts # ################################################################ - start_time = time.clock() account_ids = _get_children_and_consol(self.cr, self.uid, account_ids, form[ 'display_account_level'] and form['display_account_level'] or 100, self.context) @@ -360,7 +359,6 @@ class account_balance(report_sxw.rml_parse): credit_account_ids = list(set( credit_account_ids) - set(debit_account_ids)) - print time.clock() - start_time, "seconds" # # Generate the report lines (checking each account) # @@ -400,7 +398,6 @@ class account_balance(report_sxw.rml_parse): tot_bal3 = 0.0 tot_bal4 = 0.0 tot_bal5 = 0.0 - elif form['columns'] == 'thirteen': tot_bal1 = 0.0 tot_bal2 = 0.0 @@ -415,7 +412,6 @@ class account_balance(report_sxw.rml_parse): tot_bal11 = 0.0 tot_bal12 = 0.0 tot_bal13 = 0.0 - else: ctx_init = _ctx_init(self.context.copy()) ctx_end = _ctx_end(self.context.copy()) @@ -429,7 +425,6 @@ class account_balance(report_sxw.rml_parse): result_acc = [] tot = {} - start_time = time.clock() ############################################################### # calculos optimos # @@ -542,24 +537,11 @@ class account_balance(report_sxw.rml_parse): elif form['columns'] == 'qtr': all_account_period[p_act] = all_account - # pdb.set_trace() - # print "periodo 1 #######################" - # for i in all_account_period.get(1): - # j = all_account_period.get(1).get(i) - # print j.get('obj').name , j.get('debit') - # print "periodo 2 #######################" - # for i in all_account_period.get(2): - # j = all_account_period.get(2).get(i) - # print j.get('obj').name , j.get('debit') - # print all_account_period - print time.clock() - start_time, "seconds" - # ############################################################### # Fin de calculos optimos, sumatoria de valores # ############################################################### - start_time = time.clock() for aa_id in account_ids: id = aa_id[0] @@ -792,7 +774,6 @@ class account_balance(report_sxw.rml_parse): tot_crd += res['credit'] tot_ytd += res['ytd'] tot_eje += res['balance'] - print time.clock() - start_time, "seconds" if tot_check: str_label = form['lab_str'] From af141533f929a8c5f8d74c96a1bbacd3c3cdf40d Mon Sep 17 00:00:00 2001 From: Yanina Aular Date: Thu, 20 Jun 2013 09:06:35 -0530 Subject: [PATCH 24/35] [IMP] cleaning up unused code --- account_financial_report/report/parser.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index e5b85591..70db9545 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -413,8 +413,6 @@ class account_balance(report_sxw.rml_parse): tot_bal12 = 0.0 tot_bal13 = 0.0 else: - ctx_init = _ctx_init(self.context.copy()) - ctx_end = _ctx_end(self.context.copy()) tot_bin = 0.0 tot_deb = 0.0 tot_crd = 0.0 @@ -447,18 +445,15 @@ class account_balance(report_sxw.rml_parse): all_account_period = {} # todas las cuentas por periodo - + # iteration limit depending on the number of columns if form['columns'] == 'thirteen': limit = 13 - periods_to_use = period_ids elif form['columns'] == 'qtr': limit = 5 - periods_to_use = p else: limit = 1 for p_act in range(limit): - if limit != 1: if p_act == limit-1: form['periods'] = period_ids @@ -644,12 +639,6 @@ class account_balance(report_sxw.rml_parse): }) else: - - aa_brw_init = account_obj.browse( - self.cr, self.uid, id, ctx_init) - aa_brw_end = account_obj.browse( - self.cr, self.uid, id, ctx_end) - i, d, c = map(z, [ all_account_period['all'][id]['balanceinit'], all_account_period['all'][id]['debit'], all_account_period['all'][id]['credit']]) b = z(i+d-c) From abb7f41a0709c52fbc736d5d53dbae935a35bee0 Mon Sep 17 00:00:00 2001 From: Yanina Aular Date: Thu, 20 Jun 2013 11:07:37 -0530 Subject: [PATCH 25/35] [CC] pythonizing code --- account_financial_report/report/parser.py | 99 +++++++---------------- 1 file changed, 27 insertions(+), 72 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index 70db9545..1d8f0c47 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -36,7 +36,7 @@ from tools import config from tools.translate import _ from osv import osv import pdb - +from openerp.tools.safe_eval import safe_eval as eval class account_balance(report_sxw.rml_parse): @@ -387,31 +387,13 @@ class account_balance(report_sxw.rml_parse): p.append(l) l = [] a = 0 - + for i in range(1, 6): + eval(str('tot_bal%s'%i)+'=0.0', self.context, mode='exec', nocopy=True) elif form['columns'] == 'thirteen': period_ids = period_obj.search(self.cr, self.uid, [( 'fiscalyear_id', '=', fiscalyear.id), ('special', '=', False)], order='date_start asc') - - if form['columns'] == 'qtr': - tot_bal1 = 0.0 - tot_bal2 = 0.0 - tot_bal3 = 0.0 - tot_bal4 = 0.0 - tot_bal5 = 0.0 - elif form['columns'] == 'thirteen': - tot_bal1 = 0.0 - tot_bal2 = 0.0 - tot_bal3 = 0.0 - tot_bal4 = 0.0 - tot_bal5 = 0.0 - tot_bal6 = 0.0 - tot_bal7 = 0.0 - tot_bal8 = 0.0 - tot_bal9 = 0.0 - tot_bal10 = 0.0 - tot_bal11 = 0.0 - tot_bal12 = 0.0 - tot_bal13 = 0.0 + for i in range(1, 14): + eval(str('tot_bal%s'%i)+'=0.0', self.context, mode='exec', nocopy=True) else: tot_bin = 0.0 tot_deb = 0.0 @@ -443,9 +425,9 @@ class account_balance(report_sxw.rml_parse): account_not_black.reverse() account_not_black_ids = [i.id for i in account_not_black] - all_account_period = {} # todas las cuentas por periodo + all_account_period = {} # Todas las cuentas por periodo - # iteration limit depending on the number of columns + # Iteration limit depending on the number of columns if form['columns'] == 'thirteen': limit = 13 elif form['columns'] == 'qtr': @@ -476,52 +458,40 @@ class account_balance(report_sxw.rml_parse): account_black_init = account_obj.browse( self.cr, self.uid, account_black_ids, ctx_i) - #~ Negros + #~ Black dict_black = {} for i in account_black: - black_data = {} - black_data['obj'] = i - black_data['debit'] = i.debit - black_data['credit'] = i.credit - black_data['balance'] = i.balance + dict_black[i.id] = {'obj': i, 'debit': i.debit, 'credit':i.credit, 'balance': i.balance } if form['inf_type'] == 'BS': - black_data['balanceinit'] = 0.0 - dict_black[i.id] = black_data + dict_black.get(i.id)['balanceinit'] = 0.0 #Se adicionan los valores de balanceinit al diccionario if form['inf_type'] == 'BS': for i in account_black_init: - dict_black[i.id]['balanceinit'] = i.balance - ######################### + dict_black.get(i.id)['balanceinit'] = i.balance - #~ No negros + #~ Not black dict_not_black = {} for i in account_not_black: - not_black_data = {} - not_black_data['obj'] = i - not_black_data['debit'] = 0.0 - not_black_data['credit'] = 0.0 - not_black_data['balance'] = 0.0 + dict_not_black[i.id] = {'obj': i, 'debit': i.debit, 'credit':i.credit, 'balance': i.balance } if form['inf_type'] == 'BS': - not_black_data['balanceinit'] = 0.0 - dict_not_black[i.id] = not_black_data - ########################### + dict_not_black.get(i.id)['balanceinit'] = 0.0 all_account = dict_black.copy( ) # se hace una copia, porque se modificara for acc_id in account_not_black_ids: - acc_childs = dict_not_black[acc_id].get('obj').child_id + acc_childs = dict_not_black.get(acc_id).get('obj').child_id for child_id in acc_childs: - dict_not_black[acc_id]['debit'] += all_account[ - child_id.id].get('debit') - dict_not_black[acc_id]['credit'] += all_account[ - child_id.id].get('credit') - dict_not_black[acc_id]['balance'] += all_account[ - child_id.id].get('balance') + dict_not_black.get(acc_id)['debit'] += all_account.get( + child_id.id).get('debit') + dict_not_black.get(acc_id)['credit'] += all_account.get( + child_id.id).get('credit') + dict_not_black.get(acc_id)['balance'] += all_account.get( + child_id.id).get('balance') if form['inf_type'] == 'BS': - dict_not_black[acc_id]['balanceinit'] += all_account[ - child_id.id].get('balanceinit') + dict_not_black.get(acc_id)['balanceinit'] += all_account.get( + child_id.id).get('balanceinit') all_account[acc_id] = dict_not_black[acc_id] if p_act == limit-1: @@ -732,29 +702,14 @@ class account_balance(report_sxw.rml_parse): if form['columns'] == 'qtr': tot_check = True #~ tot[res['id']] = True - tot_bal1 += res.get('bal1', 0.0) - tot_bal2 += res.get('bal2', 0.0) - tot_bal3 += res.get('bal3', 0.0) - tot_bal4 += res.get('bal4', 0.0) - tot_bal5 += res.get('bal5', 0.0) + for i in range(1, 6): + eval("tot_bal%s += res.get('bal%s', 0.0)" % (i,i), self.context, mode='exec', nocopy=True) elif form['columns'] == 'thirteen': tot_check = True #~ tot[res['id']] = True - tot_bal1 += res.get('bal1', 0.0) - tot_bal2 += res.get('bal2', 0.0) - tot_bal3 += res.get('bal3', 0.0) - tot_bal4 += res.get('bal4', 0.0) - tot_bal5 += res.get('bal5', 0.0) - tot_bal6 += res.get('bal6', 0.0) - tot_bal7 += res.get('bal7', 0.0) - tot_bal8 += res.get('bal8', 0.0) - tot_bal9 += res.get('bal9', 0.0) - tot_bal10 += res.get('bal10', 0.0) - tot_bal11 += res.get('bal11', 0.0) - tot_bal12 += res.get('bal12', 0.0) - tot_bal13 += res.get('bal13', 0.0) - + for i in range(1, 14): + eval("tot_bal%s += res.get('bal%s', 0.0)" % (i,i), self.context, mode='exec', nocopy=True) else: tot_check = True #~ tot[res['id']] = True From a2cf3cc997951fe2c92a117a80c47858a1c0cb2c Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Thu, 20 Jun 2013 12:40:19 -0530 Subject: [PATCH 26/35] [FIX] Wrong Init values for view accounts --- account_financial_report/report/parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index 1d8f0c47..077169d9 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -473,7 +473,7 @@ class account_balance(report_sxw.rml_parse): #~ Not black dict_not_black = {} for i in account_not_black: - dict_not_black[i.id] = {'obj': i, 'debit': i.debit, 'credit':i.credit, 'balance': i.balance } + dict_not_black[i.id] = {'obj': i, 'debit': 0.0, 'credit':0.0, 'balance':0.0} if form['inf_type'] == 'BS': dict_not_black.get(i.id)['balanceinit'] = 0.0 From ce041c78bde1c732548a57578ca76b20aafa3c10 Mon Sep 17 00:00:00 2001 From: Humberto Arocha Date: Thu, 20 Jun 2013 12:55:25 -0530 Subject: [PATCH 27/35] [IMP] using debit and credit to get balance and reduce time consumption --- account_financial_report/report/parser.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index 077169d9..9e5336fa 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -461,7 +461,14 @@ class account_balance(report_sxw.rml_parse): #~ Black dict_black = {} for i in account_black: - dict_black[i.id] = {'obj': i, 'debit': i.debit, 'credit':i.credit, 'balance': i.balance } + d = i.debit + c = i.credit + dict_black[i.id] = { + 'obj': i, + 'debit': d, + 'credit': c, + 'balance': d-c + } if form['inf_type'] == 'BS': dict_black.get(i.id)['balanceinit'] = 0.0 From d4588414e876d6b57d6b89acea0f9134dad499c7 Mon Sep 17 00:00:00 2001 From: Yanina Aular Date: Thu, 20 Jun 2013 13:32:42 -0530 Subject: [PATCH 28/35] [IMP] change index --- account_financial_report/report/parser.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index 9e5336fa..b904d6d0 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -505,7 +505,7 @@ class account_balance(report_sxw.rml_parse): all_account_period['all'] = all_account else: if form['columns'] == 'thirteen': - all_account_period[period_ids[p_act]] = all_account + all_account_period[p_act] = all_account elif form['columns'] == 'qtr': all_account_period[p_act] = all_account @@ -575,11 +575,11 @@ class account_balance(report_sxw.rml_parse): elif form['columns'] == 'thirteen': pn = 1 - for p_id in period_ids: + for p_num in range(12): if form['inf_type'] == 'IS': d, c, b = map(z, [ - all_account_period[p_id].get(id).get('debit', 0.0), all_account_period[p_id].get(id).get('credit', 0.0), all_account_period[p_id].get(id).get('balance', 0.0)]) + all_account_period[p_num].get(id).get('debit', 0.0), all_account_period[p_num].get(id).get('credit', 0.0), all_account_period[p_num].get(id).get('balance', 0.0)]) res.update({ 'dbr%s' % pn: self.exchange(d), 'cdr%s' % pn: self.exchange(c), @@ -587,7 +587,7 @@ class account_balance(report_sxw.rml_parse): }) else: i, d, c = map(z, [ - all_account_period[p_id].get(id).get('balanceinit', 0.0), all_account_period[p_id].get(id).get('debit', 0.0), all_account_period[p_id].get(id).get('credit', 0.0)]) + all_account_period[p_num].get(id).get('balanceinit', 0.0), all_account_period[p_num].get(id).get('debit', 0.0), all_account_period[p_num].get(id).get('credit', 0.0)]) b = z(i+d-c) res.update({ 'dbr%s' % pn: self.exchange(d), From 1aff898d807e7311c507668e4a604997b7c225b5 Mon Sep 17 00:00:00 2001 From: Yanina Aular Date: Thu, 20 Jun 2013 14:15:35 -0530 Subject: [PATCH 29/35] [IMP] calculation with level --- account_financial_report/report/parser.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index b904d6d0..fdf75d73 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -348,9 +348,12 @@ class account_balance(report_sxw.rml_parse): ################################################################ # Get the accounts # ################################################################ + all_account_ids = _get_children_and_consol(self.cr, self.uid, account_ids, 100, self.context) + account_ids = _get_children_and_consol(self.cr, self.uid, account_ids, form[ 'display_account_level'] and form['display_account_level'] or 100, self.context) + credit_account_ids = _get_children_and_consol( self.cr, self.uid, credit_account_ids, 100, self.context, change_sign=True) @@ -411,12 +414,12 @@ class account_balance(report_sxw.rml_parse): ############################################################### account_black_ids = account_obj.search(self.cr, self.uid, ( - [('id', 'in', [i[0] for i in account_ids]), + [('id', 'in', [i[0] for i in all_account_ids]), ('type', 'not in', ('view', 'consolidation'))])) account_not_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [ - i[0] for i in account_ids]), ('type', 'in', ('view', 'consolidation'))])) + i[0] for i in all_account_ids]), ('type', 'in', ('view', 'consolidation'))])) #This could be done quickly with a sql sentence account_not_black = account_obj.browse( @@ -490,6 +493,7 @@ class account_balance(report_sxw.rml_parse): for acc_id in account_not_black_ids: acc_childs = dict_not_black.get(acc_id).get('obj').child_id for child_id in acc_childs: + #pdb.set_trace() dict_not_black.get(acc_id)['debit'] += all_account.get( child_id.id).get('debit') dict_not_black.get(acc_id)['credit'] += all_account.get( @@ -735,6 +739,12 @@ class account_balance(report_sxw.rml_parse): 'total': True, } if form['columns'] == 'qtr': + for i in range(1, 6): + bal = 'bal%s' % i + res2[bal] = eval("tot_bal%s", self.context, mode='exec', nocopy=True) + #pdb.set_trace() + #eval("tot_bal%s += res.get('bal%s', 0.0)" % (i,i), self.context, mode='exec', nocopy=True) + res2.update(dict( bal1=tot_bal1, bal2=tot_bal2, From 44b52c11de81d2f6ae1302a821d3f2887298226d Mon Sep 17 00:00:00 2001 From: Yanina Aular Date: Thu, 20 Jun 2013 15:43:20 -0530 Subject: [PATCH 30/35] [FIX] fix in reports, and deleted eval, apply z to values --- .../report/balance_full.rml | 2 +- .../report/balance_full_13_cols.rml | 26 +++--- .../report/balance_full_4_cols.rml | 4 +- .../balance_full_4_cols_analytic_ledger.rml | 6 +- .../report/balance_full_qtr_cols.rml | 10 +- account_financial_report/report/parser.py | 91 ++++++++++++------- 6 files changed, 82 insertions(+), 57 deletions(-) diff --git a/account_financial_report/report/balance_full.rml b/account_financial_report/report/balance_full.rml index 7cd03d24..ff072615 100644 --- a/account_financial_report/report/balance_full.rml +++ b/account_financial_report/report/balance_full.rml @@ -121,7 +121,7 @@ [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(a['balance'] and a['balance'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] + [[ (a['total']==True) and formatLang(a['balance'] and a['balance'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']] diff --git a/account_financial_report/report/balance_full_13_cols.rml b/account_financial_report/report/balance_full_13_cols.rml index 97d8559c..8f8ab26c 100644 --- a/account_financial_report/report/balance_full_13_cols.rml +++ b/account_financial_report/report/balance_full_13_cols.rml @@ -149,79 +149,79 @@ [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(a['bal1'] and a['bal1'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] + [[ (a['total']==True) and formatLang(a['bal1'] and a['bal1'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']] [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(a['bal2'] and a['bal2'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] + [[ (a['total']==True) and formatLang(a['bal2'] and a['bal2'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']] [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(a['bal3'] and a['bal3'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] + [[ (a['total']==True) and formatLang(a['bal3'] and a['bal3'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']] [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(a['bal4'] and a['bal4'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] + [[ (a['total']==True) and formatLang(a['bal4'] and a['bal4'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']] [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(a['bal5'] and a['bal5'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] + [[ (a['total']==True) and formatLang(a['bal5'] and a['bal5'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']] [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(a['bal6'] and a['bal6'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] + [[ (a['total']==True) and formatLang(a['bal6'] and a['bal6'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']] [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(a['bal7'] and a['bal7'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] + [[ (a['total']==True) and formatLang(a['bal7'] and a['bal7'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']] [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(a['bal8'] and a['bal8'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] + [[ (a['total']==True) and formatLang(a['bal8'] and a['bal8'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']] [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(a['bal9'] and a['bal9'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] + [[ (a['total']==True) and formatLang(a['bal9'] and a['bal9'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']] [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(a['bal10'] and a['bal10'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] + [[ (a['total']==True) and formatLang(a['bal10'] and a['bal10'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']] [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(a['bal11'] and a['bal11'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] + [[ (a['total']==True) and formatLang(a['bal11'] and a['bal11'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']] [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(a['bal12'] and a['bal12'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] + [[ (a['total']==True) and formatLang(a['bal12'] and a['bal12'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']] [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(a['bal13'] and a['bal13'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] + [[ (a['total']==True) and formatLang(a['bal13'] and a['bal13'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']] diff --git a/account_financial_report/report/balance_full_4_cols.rml b/account_financial_report/report/balance_full_4_cols.rml index 06597f1f..779b64ac 100644 --- a/account_financial_report/report/balance_full_4_cols.rml +++ b/account_financial_report/report/balance_full_4_cols.rml @@ -122,7 +122,7 @@ [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(a['balanceinit'] and a['balanceinit'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] + [[ (a['total']==True) and formatLang(a['balanceinit'] and a['balanceinit'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']] @@ -140,7 +140,7 @@ [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(a['balance'] and a['balance'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] + [[ (a['total']==True) and formatLang(a['balance'] and a['balance'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']] diff --git a/account_financial_report/report/balance_full_4_cols_analytic_ledger.rml b/account_financial_report/report/balance_full_4_cols_analytic_ledger.rml index c9c51608..8852974f 100644 --- a/account_financial_report/report/balance_full_4_cols_analytic_ledger.rml +++ b/account_financial_report/report/balance_full_4_cols_analytic_ledger.rml @@ -205,7 +205,7 @@ [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier-Bold"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(a['balanceinit'] and a['balanceinit'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] + [[ (a['total']==True) and formatLang(a['balanceinit'] and a['balanceinit'] * a.get('change_sign',1.0) or 0.0, digits=2, grouping=True) or '']] @@ -223,7 +223,7 @@ [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier-Bold"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(a['balance'] and a['balance'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] + [[ (a['total']==True) and formatLang(a['balance'] and a['balance'] * a.get('change_sign',1.0) or 0.0, digits=2, grouping=True) or '']] @@ -281,7 +281,7 @@ [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(m['balance'] and m['balance'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] + [[ (a['total']==True) and formatLang(m['balance'] and m['balance'] * a.get('change_sign',1.0) or 0.0, digits=2, grouping=True) or '']] diff --git a/account_financial_report/report/balance_full_qtr_cols.rml b/account_financial_report/report/balance_full_qtr_cols.rml index 98e6fe1d..d2f8d01c 100644 --- a/account_financial_report/report/balance_full_qtr_cols.rml +++ b/account_financial_report/report/balance_full_qtr_cols.rml @@ -125,31 +125,31 @@ [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(a['bal1'] and a['bal1'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] + [[ (a['total']==True) and formatLang(a['bal1'] and (a['bal1'] * a.get('change_sign',1)) or 0.0, digits=2, grouping=True) or '']] [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(a['bal2'] and a['bal2'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] + [[ (a['total']==True) and formatLang(a['bal2'] and a['bal2'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']] [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(a['bal3'] and a['bal3'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] + [[ (a['total']==True) and formatLang(a['bal3'] and a['bal3'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']] [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(a['bal4'] and a['bal4'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] + [[ (a['total']==True) and formatLang(a['bal4'] and a['bal4'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']] [[ a['type']<>'view' and setTag('para','para',{'fontName':"Courier"}) or removeParentNode('font') ]] - [[ (a['total']==True) and formatLang(a['bal5'] and a['bal5'] * a.get('change_sign') or 0.0, digits=2, grouping=True) or '']] + [[ (a['total']==True) and formatLang(a['bal5'] and a['bal5'] * a.get('change_sign',1) or 0.0, digits=2, grouping=True) or '']] diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index fdf75d73..d8eb654f 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -390,14 +390,30 @@ class account_balance(report_sxw.rml_parse): p.append(l) l = [] a = 0 - for i in range(1, 6): - eval(str('tot_bal%s'%i)+'=0.0', self.context, mode='exec', nocopy=True) + tot_bal1 = 0.0 + tot_bal2 = 0.0 + tot_bal3 = 0.0 + tot_bal4 = 0.0 + tot_bal5 = 0.0 elif form['columns'] == 'thirteen': period_ids = period_obj.search(self.cr, self.uid, [( 'fiscalyear_id', '=', fiscalyear.id), ('special', '=', False)], order='date_start asc') - for i in range(1, 14): - eval(str('tot_bal%s'%i)+'=0.0', self.context, mode='exec', nocopy=True) + tot_bal1 = 0.0 + tot_bal1 = 0.0 + tot_bal2 = 0.0 + tot_bal3 = 0.0 + tot_bal4 = 0.0 + tot_bal5 = 0.0 + tot_bal6 = 0.0 + tot_bal7 = 0.0 + tot_bal8 = 0.0 + tot_bal9 = 0.0 + tot_bal10 = 0.0 + tot_bal11 = 0.0 + tot_bal12 = 0.0 + tot_bal13 = 0.0 else: + ctx_end = _ctx_end(self.context.copy()) tot_bin = 0.0 tot_deb = 0.0 tot_crd = 0.0 @@ -713,14 +729,28 @@ class account_balance(report_sxw.rml_parse): if form['columns'] == 'qtr': tot_check = True #~ tot[res['id']] = True - for i in range(1, 6): - eval("tot_bal%s += res.get('bal%s', 0.0)" % (i,i), self.context, mode='exec', nocopy=True) + tot_bal1 += res.get('bal1', 0.0) + tot_bal2 += res.get('bal2', 0.0) + tot_bal3 += res.get('bal3', 0.0) + tot_bal4 += res.get('bal4', 0.0) + tot_bal5 += res.get('bal5', 0.0) elif form['columns'] == 'thirteen': tot_check = True #~ tot[res['id']] = True - for i in range(1, 14): - eval("tot_bal%s += res.get('bal%s', 0.0)" % (i,i), self.context, mode='exec', nocopy=True) + tot_bal1 += res.get('bal1', 0.0) + tot_bal2 += res.get('bal2', 0.0) + tot_bal3 += res.get('bal3', 0.0) + tot_bal4 += res.get('bal4', 0.0) + tot_bal5 += res.get('bal5', 0.0) + tot_bal6 += res.get('bal6', 0.0) + tot_bal7 += res.get('bal7', 0.0) + tot_bal8 += res.get('bal8', 0.0) + tot_bal9 += res.get('bal9', 0.0) + tot_bal10 += res.get('bal10', 0.0) + tot_bal11 += res.get('bal11', 0.0) + tot_bal12 += res.get('bal12', 0.0) + tot_bal13 += res.get('bal13', 0.0) else: tot_check = True #~ tot[res['id']] = True @@ -730,6 +760,7 @@ class account_balance(report_sxw.rml_parse): tot_ytd += res['ytd'] tot_eje += res['balance'] + #pdb.set_trace() if tot_check: str_label = form['lab_str'] res2 = { @@ -739,33 +770,27 @@ class account_balance(report_sxw.rml_parse): 'total': True, } if form['columns'] == 'qtr': - for i in range(1, 6): - bal = 'bal%s' % i - res2[bal] = eval("tot_bal%s", self.context, mode='exec', nocopy=True) - #pdb.set_trace() - #eval("tot_bal%s += res.get('bal%s', 0.0)" % (i,i), self.context, mode='exec', nocopy=True) - res2.update(dict( - bal1=tot_bal1, - bal2=tot_bal2, - bal3=tot_bal3, - bal4=tot_bal4, - bal5=tot_bal5,)) + bal1=z(tot_bal1), + bal2=z(tot_bal2), + bal3=z(tot_bal3), + bal4=z(tot_bal4), + bal5=z(tot_bal5),)) elif form['columns'] == 'thirteen': res2.update(dict( - bal1=tot_bal1, - bal2=tot_bal2, - bal3=tot_bal3, - bal4=tot_bal4, - bal5=tot_bal5, - bal6=tot_bal6, - bal7=tot_bal7, - bal8=tot_bal8, - bal9=tot_bal9, - bal10=tot_bal10, - bal11=tot_bal11, - bal12=tot_bal12, - bal13=tot_bal13,)) + bal1=z(tot_bal1), + bal2=z(tot_bal2), + bal3=z(tot_bal3), + bal4=z(tot_bal4), + bal5=z(tot_bal5), + bal6=z(tot_bal6), + bal7=z(tot_bal7), + bal8=z(tot_bal8), + bal9=z(tot_bal9), + bal10=z(tot_bal10), + bal11=z(tot_bal11), + bal12=z(tot_bal12), + bal13=z(tot_bal13),)) else: res2.update({ @@ -777,7 +802,7 @@ class account_balance(report_sxw.rml_parse): }) result_acc.append(res2) - return result_acc + return result_acc report_sxw.report_sxw('report.afr.1cols', 'wizard.report', From 14b4528902156eee87ddf2c71a485a4a9f2f30af Mon Sep 17 00:00:00 2001 From: Yanina Aular Date: Thu, 20 Jun 2013 16:08:41 -0530 Subject: [PATCH 31/35] [FIX] --- account_financial_report/report/parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_financial_report/report/parser.py b/account_financial_report/report/parser.py index d8eb654f..9e718d4e 100644 --- a/account_financial_report/report/parser.py +++ b/account_financial_report/report/parser.py @@ -802,7 +802,7 @@ class account_balance(report_sxw.rml_parse): }) result_acc.append(res2) - return result_acc + return result_acc report_sxw.report_sxw('report.afr.1cols', 'wizard.report', From 548cc733051b680ca2bd9b4f3bdaa6197d71c810 Mon Sep 17 00:00:00 2001 From: Yanina Aular Date: Thu, 20 Jun 2013 16:11:18 -0530 Subject: [PATCH 32/35] [IMP] 12 columns rml --- .../report/balance_full_13_cols.rml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/account_financial_report/report/balance_full_13_cols.rml b/account_financial_report/report/balance_full_13_cols.rml index 8f8ab26c..6a68b3e2 100644 --- a/account_financial_report/report/balance_full_13_cols.rml +++ b/account_financial_report/report/balance_full_13_cols.rml @@ -4,7 +4,7 @@ - + [[company.logo and company.logo or removeParentNode('image')]]