I want to get the Previous Balance Sheet report to compare it in new balance sheet.. There is no error appear but it doesn't get the id of the previous data of my balance sheet. can someone please help me. thanks in advance..
here my codes:
def _build_context_prev(self, cr, uid, ids, data, context=None):
if context is None:
context = {}
result = {}
result['fiscalyear'] = 'fiscalyear_id' in data['form'] and data['form']['fiscalyear_id'] or False
fiscal_ids = self.pool.get('account.fiscalyear').search(cr,uid,[('id','=',result['fiscalyear'])])
#fiscal_ids1 = self.pool.get('account.fiscalyear').search(cr,uid,[('','=',result['fiscalyear'])])
fiscal_year1= 'fiscalyear_id' in data['form'] and data['form']['fiscalyear_id'] or False
period_from1 = False
period_to1 = False
date_from1 =''
date_to1 = ''
year1 = ''
for fiscal in self.pool.get('account.fiscalyear').browse(cr,uid,fiscal_ids):
max_date = fiscal.date_stop
fiscal_ids1 = self.pool.get('account.fiscalyear').search(cr,uid,[('date_stop','<',max_date)])
max_date1= ''
for fiscal1 in self.pool.get('account.fiscalyear').browse(cr,uid,fiscal_ids1):
netsvc.Logger().notifyChannel("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOPPPPP555555555555555555555AAAA!!!:: ",netsvc.LOG_INFO, '' + str(max_date))
netsvc.Logger().notifyChannel("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOPPPPP555555555555555555555BBBB!!!:: ",netsvc.LOG_INFO, '' + str(fiscal1.date_stop))
netsvc.Logger().notifyChannel("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOPPPPP555555555555555555555CCCC!!!:: ",netsvc.LOG_INFO, '' + str(max_date1))
if max_date1 == '':
max_date1 = fiscal1.date_stop
elif date(max_date) > fiscal1.date_stop & date(max_date1) <= fiscal1.date_stop:
max_date1 = fiscal1.date_stop
fiscal_year1 = fiscal1.id
#year
"""period_ids = self.pool.get('account.period').search(cr,uid,[('fiscal_year_id','=', fiscal1.id)])
max_period1= False
for period in self.pool.get('account.period').browse(cr,uid,period_ids):
if max_period1 != :
max_period1= period.id
if max_period1 < period.date_stop:"""
result['fiscalyear'] = fiscal_year1
result['journal_ids'] = 'journal_ids' in data['form'] and data['form']['journal_ids'] or False
result['chart_account_id'] = 'chart_account_id' in data['form'] and data['form']['chart_account_id'] or False
if data['form']['filter'] == 'filter_date':
result['date_from'] = data['form']['date_from']
result['date_to'] = data['form']['date_to']
elif data['form']['filter'] == 'filter_period':
if not data['form']['period_from'] or not data['form']['period_to']:
raise osv.except_osv(_('Error!'),_('Select a starting and an ending period.'))
result['period_from'] = data['form']['period_from']
result['period_to'] = data['form']['period_to']
netsvc.Logger().notifyChannel("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOPPPPPPPPPPPPPPPPPPPPPPPPPPPPP44444444444!!!:: ",netsvc.LOG_INFO, '' + str(result))
return result
Heres the error occured:
Server Traceback (most recent call last): File "/opt/openerp/server-7/openerp/addons/web/session.py", line 90, in send return openerp.netsvc.dispatch_rpc(service_name, method, args) File "/opt/openerp/server-7/openerp/netsvc.py", line 293, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "/opt/openerp/server-7/openerp/service/web_services.py", line 626, in dispatch res = fn(db, uid, *params) File "/opt/openerp/server-7/openerp/osv/osv.py", line 188, in execute_kw return self.execute(db, uid, obj, method, *args, **kw or {}) File "/opt/openerp/server-7/openerp/osv/osv.py", line 131, in wrapper return f(self, dbname, *args, **kwargs) File "/opt/openerp/server-7/openerp/osv/osv.py", line 197, in execute res = self.execute_cr(cr, uid, obj, method, *args, **kw) File "/opt/openerp/server-7/openerp/osv/osv.py", line 185, in execute_cr return getattr(object, method)(cr, uid, *args, **kw) File "/opt/openerp/biz1_server70_addons/biz1_cash_flow1/accounting_report.py", line 139, in check_report1 used_context1 = self._build_context_prev(cr, uid, ids, res['datas'], context=context) File "/opt/openerp/biz1_server70_addons/biz1_cash_flow1/accounting_report.py",
line 86, in _build_context_prev elif date(max_date) > fiscal1.date_stop & date(max_date1) > fiscal1.date_stop:
TypeError: an integer is required
Well clearly something isn't an integer...max_date ||| max_date1 ||| fiscal1.date_stop .. type check these first. eg: print "TypeCheck: {0}".format(type(max_date))