Browse Source

[MERGE][From trunk]

pull/7/merge
Fernando.rangel 12 years ago
parent
commit
069a36c65f
  1. 5
      account_financial_report/model/account_financial_report.py
  2. 66
      account_financial_report/report/parser.py
  3. 1
      account_financial_report/view/account_financial_report_view.xml
  4. 1
      account_financial_report/view/wizard.xml
  5. 5
      account_financial_report/wizard/wizard.py

5
account_financial_report/model/account_financial_report.py

@ -52,6 +52,10 @@ class account_financial_report(osv.osv):
'tot_check': fields.boolean('Summarize?', help='Checking will add a new line at the end of the Report which will Summarize Columns in Report'), 'tot_check': fields.boolean('Summarize?', help='Checking will add a new line at the end of the Report which will Summarize Columns in Report'),
'lab_str': fields.char('Description', help='Description for the Summary', size=128), 'lab_str': fields.char('Description', help='Description for the Summary', size=128),
'target_move': fields.selection([('posted', 'All Posted Entries'),
('all', 'All Entries'),
], 'Entries to Include', required=True,
help='Print All Accounting Entries or just Posted Accounting Entries'),
#~ Deprecated fields #~ Deprecated fields
'filter': fields.selection([('bydate', 'By Date'), ('byperiod', 'By Period'), ('all', 'By Date and Period'), ('none', 'No Filter')], 'Date/Period Filter'), 'filter': fields.selection([('bydate', 'By Date'), ('byperiod', 'By Period'), ('all', 'By Date and Period'), ('none', 'No Filter')], 'Date/Period Filter'),
@ -70,6 +74,7 @@ class account_financial_report(osv.osv):
'date_from': lambda *a: time.strftime('%Y-%m-%d'), 'date_from': lambda *a: time.strftime('%Y-%m-%d'),
'date_to': lambda *a: time.strftime('%Y-%m-%d'), 'date_to': lambda *a: time.strftime('%Y-%m-%d'),
'filter': lambda *a: 'byperiod', 'filter': lambda *a: 'byperiod',
'target_move': 'posted',
} }
def copy(self, cr, uid, id, defaults, context=None): def copy(self, cr, uid, id, defaults, context=None):

66
account_financial_report/report/parser.py

@ -181,7 +181,8 @@ class account_balance(report_sxw.rml_parse):
#~ periods = str(tuple(ctx['periods'])) #~ periods = str(tuple(ctx['periods']))
where = """where aml.period_id in (%s) and aa.id = %s and aml.state <> 'draft'""" % ( where = """where aml.period_id in (%s) and aa.id = %s and aml.state <> 'draft'""" % (
periods, account['id']) periods, account['id'])
if ctx.get('state','posted')=='posted':
where += "AND am.state = 'posted'"
sql_detalle = """select aml.id as id, aj.name as diario, aa.name as descripcion, sql_detalle = """select aml.id as id, aj.name as diario, aa.name as descripcion,
(select name from res_partner where aml.partner_id = id) as partner, (select name from res_partner where aml.partner_id = id) as partner,
aa.code as cuenta, aml.name as name, aa.code as cuenta, aml.name as name,
@ -321,6 +322,8 @@ class account_balance(report_sxw.rml_parse):
def z(n): def z(n):
return abs(n) < 0.005 and 0.0 or n return abs(n) < 0.005 and 0.0 or n
self.context['state'] = form['target_move'] or 'posted'
self.from_currency_id = self.get_company_currency(form['company_id'] and type(form[ self.from_currency_id = self.get_company_currency(form['company_id'] and type(form[
'company_id']) in (list, tuple) and form['company_id'][0] or form['company_id']) 'company_id']) in (list, tuple) and form['company_id'][0] or form['company_id'])
if not form['currency_id']: if not form['currency_id']:
@ -331,6 +334,7 @@ class account_balance(report_sxw.rml_parse):
if 'account_list' in form and form['account_list']: if 'account_list' in form and form['account_list']:
account_ids = form['account_list'] account_ids = form['account_list']
account_list= form['account_list']
del form['account_list'] del form['account_list']
credit_account_ids = self.get_company_accounts(form['company_id'] and type(form[ credit_account_ids = self.get_company_accounts(form['company_id'] and type(form[
@ -436,7 +440,28 @@ class account_balance(report_sxw.rml_parse):
('view', 'consolidation'))])) ('view', 'consolidation'))]))
account_not_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [ account_not_black_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [
i[0] for i in all_account_ids]), ('type', 'in', ('view', 'consolidation'))]))
i[0] for i in all_account_ids]),('type', '=', 'view')]))
acc_cons_ids = account_obj.search(self.cr, self.uid, ([('id', 'in', [
i[0] for i in all_account_ids]), ('type', 'in', ('consolidation',))]))
account_consol_ids = acc_cons_ids and account_obj._get_children_and_consol(
self.cr, self.uid, acc_cons_ids) or []
account_black_ids += account_obj.search(self.cr, self.uid, (
[('id', 'in', account_consol_ids ),
('type', 'not in',
('view', 'consolidation'))]))
account_black_ids = list(set(account_black_ids))
c_account_not_black_ids = account_obj.search(self.cr, self.uid, ([
('id', 'in', account_consol_ids),
('type', '=', 'view')]))
delete_cons = False
if c_account_not_black_ids:
delete_cons = set(account_not_black_ids) & set(c_account_not_black_ids) and True or False
account_not_black_ids = list(set(account_not_black_ids) - set(c_account_not_black_ids))
# This could be done quickly with a sql sentence # This could be done quickly with a sql sentence
account_not_black = account_obj.browse( account_not_black = account_obj.browse(
@ -445,6 +470,25 @@ class account_balance(report_sxw.rml_parse):
account_not_black.reverse() account_not_black.reverse()
account_not_black_ids = [i.id for i in account_not_black] account_not_black_ids = [i.id for i in account_not_black]
c_account_not_black = account_obj.browse(
self.cr, self.uid, c_account_not_black_ids)
c_account_not_black.sort(key=lambda x: x.level)
c_account_not_black.reverse()
c_account_not_black_ids = [i.id for i in c_account_not_black]
if delete_cons:
account_not_black_ids = c_account_not_black_ids + account_not_black_ids
account_not_black = c_account_not_black + account_not_black
else:
acc_cons_brw = account_obj.browse(
self.cr, self.uid, acc_cons_ids)
acc_cons_brw.sort(key=lambda x: x.level)
acc_cons_brw.reverse()
acc_cons_ids = [i.id for i in acc_cons_brw]
account_not_black_ids = c_account_not_black_ids + acc_cons_ids + account_not_black_ids
account_not_black = c_account_not_black + acc_cons_brw + account_not_black
all_account_period = {} # All accounts per period all_account_period = {} # All accounts per period
# Iteration limit depending on the number of columns # Iteration limit depending on the number of columns
@ -510,8 +554,12 @@ class account_balance(report_sxw.rml_parse):
) #It makes a copy because they modify ) #It makes a copy because they modify
for acc_id in account_not_black_ids: for acc_id in account_not_black_ids:
acc_childs = dict_not_black.get(acc_id).get('obj').child_id
acc_childs = dict_not_black.get(acc_id).get('obj').type=='view' \
and dict_not_black.get(acc_id).get('obj').child_id \
or dict_not_black.get(acc_id).get('obj').child_consol_ids
for child_id in acc_childs: for child_id in acc_childs:
if child_id.type == 'consolidation' and delete_cons:
continue
dict_not_black.get(acc_id)['debit'] += all_account.get( dict_not_black.get(acc_id)['debit'] += all_account.get(
child_id.id).get('debit') child_id.id).get('debit')
dict_not_black.get(acc_id)['credit'] += all_account.get( dict_not_black.get(acc_id)['credit'] += all_account.get(
@ -538,7 +586,8 @@ class account_balance(report_sxw.rml_parse):
for aa_id in account_ids: for aa_id in account_ids:
id = aa_id[0] id = aa_id[0]
if aa_id[3].type == 'consolidation' and delete_cons:
continue
# #
# Check if we need to include this level # Check if we need to include this level
# #
@ -725,11 +774,10 @@ class account_balance(report_sxw.rml_parse):
# #
# Check whether we must sumarize this line in the report or not # Check whether we must sumarize this line in the report or not
# #
if form['tot_check'] and res['type'] == 'view' and res['level'] == 1 and (res['id'] not in tot):
if form['tot_check'] and (res['id'] in account_list) and (res['id'] not in tot):
if form['columns'] == 'qtr': if form['columns'] == 'qtr':
tot_check = True tot_check = True
#~ tot[res['id']] = True
tot[res['id']] = True
tot_bal1 += res.get('bal1', 0.0) tot_bal1 += res.get('bal1', 0.0)
tot_bal2 += res.get('bal2', 0.0) tot_bal2 += res.get('bal2', 0.0)
tot_bal3 += res.get('bal3', 0.0) tot_bal3 += res.get('bal3', 0.0)
@ -738,7 +786,7 @@ class account_balance(report_sxw.rml_parse):
elif form['columns'] == 'thirteen': elif form['columns'] == 'thirteen':
tot_check = True tot_check = True
#~ tot[res['id']] = True
tot[res['id']] = True
tot_bal1 += res.get('bal1', 0.0) tot_bal1 += res.get('bal1', 0.0)
tot_bal2 += res.get('bal2', 0.0) tot_bal2 += res.get('bal2', 0.0)
tot_bal3 += res.get('bal3', 0.0) tot_bal3 += res.get('bal3', 0.0)
@ -754,7 +802,7 @@ class account_balance(report_sxw.rml_parse):
tot_bal13 += res.get('bal13', 0.0) tot_bal13 += res.get('bal13', 0.0)
else: else:
tot_check = True tot_check = True
#~ tot[res['id']] = True
tot[res['id']] = True
tot_bin += res['balanceinit'] tot_bin += res['balanceinit']
tot_deb += res['debit'] tot_deb += res['debit']
tot_crd += res['credit'] tot_crd += res['credit']

1
account_financial_report/view/account_financial_report_view.xml

@ -39,6 +39,7 @@
<group string="Accounts Info" > <group string="Accounts Info" >
<field name="display_account" required="True" /> <field name="display_account" required="True" />
<field name="display_account_level" required="True" /> <field name="display_account_level" required="True" />
<field name="target_move"/>
</group> </group>
<group string="FiscalYear Info" > <group string="FiscalYear Info" >
<field name="fiscalyear_id" on_change='onchange_columns(columns,fiscalyear_id,period_ids)' <field name="fiscalyear_id" on_change='onchange_columns(columns,fiscalyear_id,period_ids)'

1
account_financial_report/view/wizard.xml

@ -51,6 +51,7 @@
<group string="Accounts Info"> <group string="Accounts Info">
<field name="display_account" required="True" /> <field name="display_account" required="True" />
<field name="display_account_level" required="True" /> <field name="display_account_level" required="True" />
<field name="target_move"/>
</group> </group>
<group string="FiscalYear Info"> <group string="FiscalYear Info">
<field name="fiscalyear" on_change='onchange_columns(columns,fiscalyear,periods)' domain="[('company_id','=',company_id)]"/> <field name="fiscalyear" on_change='onchange_columns(columns,fiscalyear,periods)' domain="[('company_id','=',company_id)]"/>

5
account_financial_report/wizard/wizard.py

@ -55,6 +55,10 @@ class wizard_report(osv.osv_memory):
'tot_check': fields.boolean('Summarize?', help='Checking will add a new line at the end of the Report which will Summarize Columns in Report'), 'tot_check': fields.boolean('Summarize?', help='Checking will add a new line at the end of the Report which will Summarize Columns in Report'),
'lab_str': fields.char('Description', help='Description for the Summary', size=128), 'lab_str': fields.char('Description', help='Description for the Summary', size=128),
'target_move': fields.selection([('posted', 'All Posted Entries'),
('all', 'All Entries'),
], 'Entries to Include', required=True,
help='Print All Accounting Entries or just Posted Accounting Entries'),
#~ Deprecated fields #~ Deprecated fields
'filter': fields.selection([('bydate', 'By Date'), ('byperiod', 'By Period'), ('all', 'By Date and Period'), ('none', 'No Filter')], 'Date/Period Filter'), 'filter': fields.selection([('bydate', 'By Date'), ('byperiod', 'By Period'), ('all', 'By Date and Period'), ('none', 'No Filter')], 'Date/Period Filter'),
'date_to': fields.date('End date'), 'date_to': fields.date('End date'),
@ -71,6 +75,7 @@ class wizard_report(osv.osv_memory):
'fiscalyear': lambda self, cr, uid, c: self.pool.get('account.fiscalyear').find(cr, uid), 'fiscalyear': lambda self, cr, uid, c: self.pool.get('account.fiscalyear').find(cr, uid),
'display_account': lambda *a: 'bal_mov', 'display_account': lambda *a: 'bal_mov',
'columns': lambda *a: 'five', 'columns': lambda *a: 'five',
'target_move': 'posted',
} }
def onchange_inf_type(self, cr, uid, ids, inf_type, context=None): def onchange_inf_type(self, cr, uid, ids, inf_type, context=None):

Loading…
Cancel
Save