add two reports account balance and general ledger to new menu item generic report in account
bzr revid: mra@tinyerp.com-20081010130333-v39h7n1glvnbiwtf
This commit is contained in:
parent
a39c3fb57f
commit
430b794aac
|
@ -16,5 +16,6 @@
|
|||
|
||||
<menuitem id="menu_finance_periodical_processing" name="Periodical Processing" parent="account.menu_finance" sequence="3"/>
|
||||
<menuitem id="menu_account_end_year_treatments" name="End of Year Treatments" parent="account.menu_finance_periodical_processing" sequence="20"/>
|
||||
<menuitem id="menu_generic_report" name="Generic Reports" parent="account.menu_finance" sequence="8"/>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -78,5 +78,14 @@
|
|||
|
||||
<!-- account.invoice -->
|
||||
<wizard string="Open State" model="account.invoice" name="account.wizard_paid_open" menu="False" id="wizard_paid_open"/>
|
||||
|
||||
<!-- generic report wizard -->
|
||||
<wizard id="wizard_account_balance_report" menu="False" model="account.account" name="account.account.balance.report" string="Account balance"/>
|
||||
<menuitem icon="STOCK_PRINT" action="wizard_account_balance_report" id="menu_account_balance_report" parent="account.menu_generic_report" type="wizard"/>
|
||||
|
||||
<wizard id="wizard_general_ledger" menu="False" model="account.account" name="account.general.ledger.report" string="General ledger"/>
|
||||
<menuitem icon="STOCK_PRINT" action="wizard_general_ledger" id="menu_general_ledger" parent="account.menu_generic_report" type="wizard"/>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -35,7 +35,7 @@ import datetime
|
|||
from report import report_sxw
|
||||
|
||||
class account_balance(report_sxw.rml_parse):
|
||||
|
||||
|
||||
_name = 'report.account.account.balance'
|
||||
def __init__(self, cr, uid, name, context):
|
||||
super(account_balance, self).__init__(cr, uid, name, context)
|
||||
|
@ -53,20 +53,20 @@ class account_balance(report_sxw.rml_parse):
|
|||
'get_periods':self.get_periods,
|
||||
})
|
||||
self.context = context
|
||||
|
||||
|
||||
def get_fiscalyear(self, form):
|
||||
res=[]
|
||||
if form.has_key('fiscalyear'):
|
||||
if form.has_key('fiscalyear'):
|
||||
fisc_id = form['fiscalyear']
|
||||
if not (fisc_id):
|
||||
return ''
|
||||
self.cr.execute("select name from account_fiscalyear where id = %d" %(int(fisc_id)))
|
||||
res=self.cr.fetchone()
|
||||
return res and res[0] or ''
|
||||
|
||||
|
||||
def get_periods(self, form):
|
||||
result=''
|
||||
if form.has_key('periods'):
|
||||
if form.has_key('periods'):
|
||||
period_ids = ",".join([str(x) for x in form['periods'][0][2] if x])
|
||||
self.cr.execute("select name from account_period where id in (%s)" % (period_ids))
|
||||
res=self.cr.fetchall()
|
||||
|
@ -76,7 +76,7 @@ class account_balance(report_sxw.rml_parse):
|
|||
else:
|
||||
result+=r[0]+", "
|
||||
return str(result and result[:-1]) or ''
|
||||
|
||||
|
||||
def lines(self, form, ids={}, done=None, level=1):
|
||||
if not ids:
|
||||
ids = self.ids
|
||||
|
@ -84,10 +84,13 @@ class account_balance(report_sxw.rml_parse):
|
|||
return []
|
||||
if not done:
|
||||
done={}
|
||||
if form.has_key('Account_list') and form['Account_list']:
|
||||
ids = [form['Account_list']]
|
||||
del form['Account_list']
|
||||
res={}
|
||||
result_acc=[]
|
||||
ctx = self.context.copy()
|
||||
if form.has_key('fiscalyear'):
|
||||
if form.has_key('fiscalyear'):
|
||||
self.transform_period_into_date_array(form)
|
||||
ctx['fiscalyear'] = form['fiscalyear']
|
||||
ctx['periods'] = form['periods'][0][2]
|
||||
|
@ -95,7 +98,7 @@ class account_balance(report_sxw.rml_parse):
|
|||
self.transform_date_into_date_array(form)
|
||||
ctx['date_from'] = form['date_from']
|
||||
ctx['date_to'] = form['date_to']
|
||||
|
||||
|
||||
accounts = self.pool.get('account.account').browse(self.cr, self.uid, ids, ctx)
|
||||
def cmp_code(x, y):
|
||||
return cmp(x.code, y.code)
|
||||
|
@ -103,7 +106,7 @@ class account_balance(report_sxw.rml_parse):
|
|||
for account in accounts:
|
||||
if account.id in done:
|
||||
continue
|
||||
done[account.id] = 1
|
||||
done[account.id] = 1
|
||||
res = {
|
||||
'lid' :'',
|
||||
'date':'',
|
||||
|
@ -140,7 +143,7 @@ class account_balance(report_sxw.rml_parse):
|
|||
if form['display_account'] == 'bal_mouvement':
|
||||
if res['credit'] <> 0 or res['debit'] <> 0 or res['balance'] <> 0:
|
||||
result_acc.append(res)
|
||||
elif form['display_account'] == 'bal_solde':
|
||||
elif form['display_account'] == 'bal_solde':
|
||||
if res['balance'] <> 0:
|
||||
result_acc.append(res)
|
||||
else:
|
||||
|
@ -156,7 +159,7 @@ class account_balance(report_sxw.rml_parse):
|
|||
ids2.sort()
|
||||
result_acc += self.lines(form, [x[1] for x in ids2], done, level+1)
|
||||
return result_acc
|
||||
|
||||
|
||||
def moveline(self,form,ids,level):
|
||||
res={}
|
||||
self.date_lst_string = '\'' + '\',\''.join(map(str,self.date_lst)) + '\''
|
||||
|
@ -168,7 +171,7 @@ class account_balance(report_sxw.rml_parse):
|
|||
"WHERE l.account_id = '"+str(ids)+"' " \
|
||||
"AND l.date IN (" + self.date_lst_string + ") " \
|
||||
"ORDER BY l.id")
|
||||
res = self.cr.dictfetchall()
|
||||
res = self.cr.dictfetchall()
|
||||
sum = 0.0
|
||||
for r in res:
|
||||
sum = r['debit1'] - r['credit1']
|
||||
|
@ -186,7 +189,7 @@ class account_balance(report_sxw.rml_parse):
|
|||
else:
|
||||
r['bal_type']=" Cr."
|
||||
return res or ''
|
||||
|
||||
|
||||
def date_range(self,start,end):
|
||||
start = datetime.date.fromtimestamp(time.mktime(time.strptime(start,"%Y-%m-%d")))
|
||||
end = datetime.date.fromtimestamp(time.mktime(time.strptime(end,"%Y-%m-%d")))
|
||||
|
@ -198,7 +201,7 @@ class account_balance(report_sxw.rml_parse):
|
|||
for date in date_array:
|
||||
full_str_date.append(str(date))
|
||||
return full_str_date
|
||||
|
||||
|
||||
#
|
||||
def transform_period_into_date_array(self,form):
|
||||
## Get All Period Date
|
||||
|
@ -206,23 +209,23 @@ class account_balance(report_sxw.rml_parse):
|
|||
periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',form['fiscalyear'])])
|
||||
else:
|
||||
periods_id = form['periods'][0][2]
|
||||
date_array = []
|
||||
date_array = []
|
||||
for period_id in periods_id:
|
||||
period_obj = self.pool.get('account.period').browse(self.cr, self.uid, period_id)
|
||||
date_array = date_array + self.date_range(period_obj.date_start,period_obj.date_stop)
|
||||
|
||||
|
||||
self.date_lst = date_array
|
||||
self.date_lst.sort()
|
||||
|
||||
|
||||
def transform_date_into_date_array(self,form):
|
||||
return_array = self.date_range(form['date_from'],form['date_to'])
|
||||
self.date_lst = return_array
|
||||
self.date_lst.sort()
|
||||
|
||||
|
||||
def _sum_credit(self):
|
||||
return self.sum_credit
|
||||
|
||||
return self.sum_credit
|
||||
|
||||
def _sum_debit(self):
|
||||
return self.sum_debit
|
||||
return self.sum_debit
|
||||
report_sxw.report_sxw('report.account.account.balance', 'account.account', 'addons/account/report/account_balance.rml', parser=account_balance, header=False)
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ dates_form = '''<?xml version="1.0"?>
|
|||
<field name="date_from" colspan="4"/>
|
||||
<field name="date_to" colspan="4"/>
|
||||
<field name="display_account" colspan="4"/>
|
||||
|
||||
|
||||
</form>'''
|
||||
|
||||
dates_fields = {
|
||||
|
@ -55,7 +55,7 @@ period_form = '''<?xml version="1.0"?>
|
|||
<field name="fiscalyear" colspan="4"/>
|
||||
<field name="periods" colspan="4"/>
|
||||
<field name="display_account" colspan="4"/>
|
||||
|
||||
|
||||
</form>'''
|
||||
|
||||
|
||||
|
@ -73,7 +73,7 @@ account_form = '''<?xml version="1.0"?>
|
|||
</form>'''
|
||||
|
||||
account_fields = {
|
||||
'Account_list': {'string':'Account', 'type':'many2one', 'relation':'account.account', 'required':True},
|
||||
'Account_list': {'string':'Account', 'type':'many2one', 'relation':'account.account', 'required':True ,'domain':[('parent_id','=',False)]},
|
||||
}
|
||||
|
||||
|
||||
|
@ -97,7 +97,7 @@ class wizard_report(wizard.interface):
|
|||
else:
|
||||
return 'account_selection'
|
||||
|
||||
|
||||
|
||||
def _check_date(self, cr, uid, data, context):
|
||||
sql = """
|
||||
SELECT f.id, f.date_start, f.date_stop FROM account_fiscalyear f Where '%s' between f.date_start and f.date_stop """%(data['form']['date_from'])
|
||||
|
@ -108,12 +108,12 @@ class wizard_report(wizard.interface):
|
|||
raise wizard.except_wizard('UserError','Date to must be set between ' + res[0]['date_start'] + " and " + res[0]['date_stop'])
|
||||
else:
|
||||
return 'report'
|
||||
|
||||
|
||||
else:
|
||||
raise wizard.except_wizard('UserError','Date not in a defined fiscal year')
|
||||
|
||||
states = {
|
||||
|
||||
|
||||
'init': {
|
||||
'actions': [],
|
||||
'result': {'type':'choice','next_state':_check_path}
|
||||
|
|
|
@ -61,7 +61,7 @@ account_form = '''<?xml version="1.0"?>
|
|||
</form>'''
|
||||
|
||||
account_fields = {
|
||||
'Account_list': {'string':'Account', 'type':'many2one', 'relation':'account.account', 'required':True},
|
||||
'Account_list': {'string':'Account', 'type':'many2one', 'relation':'account.account', 'required':True ,'domain':[('parent_id','=',False)]},
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,7 +110,7 @@ def _check_date(self, cr, uid, data, context):
|
|||
raise wizard.except_wizard('UserError','Date to must be set between ' + res[0]['date_start'] + " and " + res[0]['date_stop'])
|
||||
else:
|
||||
return 'checkreport'
|
||||
|
||||
|
||||
else:
|
||||
raise wizard.except_wizard('UserError','Date not in a defined fiscal year')
|
||||
|
||||
|
@ -119,13 +119,13 @@ class wizard_report(wizard.interface):
|
|||
def _get_defaults(self, cr, uid, data, context):
|
||||
fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear')
|
||||
data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid)
|
||||
data['form']['sortbydate'] = 'sort_date'
|
||||
data['form']['sortbydate'] = 'sort_date'
|
||||
data['form']['display_account']='bal_all'
|
||||
data['form']['landscape']=True
|
||||
data['form']['amount_currency'] = True
|
||||
return data['form']
|
||||
def _get_defaults_fordate(self, cr, uid, data, context):
|
||||
data['form']['sortbydate'] = 'sort_date'
|
||||
data['form']['sortbydate'] = 'sort_date'
|
||||
data['form']['display_account']='bal_all'
|
||||
data['form']['landscape']=True
|
||||
data['form']['amount_currency'] = True
|
||||
|
|
Loading…
Reference in New Issue