From bf866163acb3f42e4fc3c4e24511ad285ebd10ad Mon Sep 17 00:00:00 2001 From: apa-tiny Date: Thu, 16 Oct 2008 19:30:26 +0530 Subject: [PATCH] =?UTF-8?q?for=20reports,=20partner=20balance=20et=20partn?= =?UTF-8?q?er=20ledger.=20Can=20u=20change=20this=20to=20not=20have=20the?= =?UTF-8?q?=20wizard=20that=20asks=20by=20date=20or=20by=20period=20when?= =?UTF-8?q?=20we=20run=20the=20wizard.=20We=20should=20include=20a=20field?= =?UTF-8?q?=20selection=20filter=20with=20that=20values=20=C2=A0=20No=20on?= =?UTF-8?q?e=20=C2=A0=20By=20date=20=C2=A0=20By=20period=20With=20attrs,?= =?UTF-8?q?=20the=20fields=20'date=20from=20et=20date=20to'=20and=20=20Per?= =?UTF-8?q?iod=20should=20print=20or=20not=20depending=20on=20the=20value?= =?UTF-8?q?=20of=20the=20field=20selection.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bzr revid: patelamit2003@gmail.com-20081016140026-xi90zggjh51zvkwa --- addons/account/report/partner_balance.py | 13 +- .../wizard/wizard_partner_balance_report.py | 141 +++++++++++------- 2 files changed, 93 insertions(+), 61 deletions(-) diff --git a/addons/account/report/partner_balance.py b/addons/account/report/partner_balance.py index d7e82431ce4..0e9b0777d14 100644 --- a/addons/account/report/partner_balance.py +++ b/addons/account/report/partner_balance.py @@ -85,6 +85,7 @@ class partner_balance(report_sxw.rml_parse): def transform_date_into_date_array(self,data): + return_array = self.date_range(data['form']['date1'],data['form']['date2']) self.date_lst = return_array self.date_lst.sort() @@ -109,9 +110,12 @@ class partner_balance(report_sxw.rml_parse): # Transformation des date # # - if data['form'].has_key('fiscalyear'): + + if data['form']['fiscalyear']: + print"data['form']['fiscalyear']=True" self.transform_period_into_date_array(data) else: + print"data['form']['fiscalyear']=False" self.transform_date_into_date_array(data) ## self.date_lst_string = '\'' + '\',\''.join(map(str,self.date_lst)) + '\'' @@ -202,7 +206,7 @@ class partner_balance(report_sxw.rml_parse): "GROUP BY p.id, p.ref, p.name,l.account_id,ac.name,ac.code " \ "ORDER BY l.account_id,p.name") res = self.cr.dictfetchall() - print"=====res=====",res + for r in res: full_account.append(r) @@ -241,7 +245,7 @@ class partner_balance(report_sxw.rml_parse): # r['type'] = 1 r['balance'] = float(r['sdebit']) - float(r['scredit']) - print"====i = 0 :completearray====",completearray,i + completearray.append(r) # tot_debit = r['debit'] @@ -303,7 +307,7 @@ class partner_balance(report_sxw.rml_parse): r['balance'] = float(r['sdebit']) - float(r['scredit']) # completearray.append(r) - print"====i!=0 completearray====",completearray,i + if cleanarray[i]['account_id'] == cleanarray[i-1]['account_id']: # we reset the counter @@ -332,6 +336,7 @@ class partner_balance(report_sxw.rml_parse): result_tmp = 0.0 # # + if data['form']['soldeinit'] : self.cr.execute( 'SELECT sum(debit) ' \ diff --git a/addons/account/wizard/wizard_partner_balance_report.py b/addons/account/wizard/wizard_partner_balance_report.py index 08af6074215..7334bfc56fc 100644 --- a/addons/account/wizard/wizard_partner_balance_report.py +++ b/addons/account/wizard/wizard_partner_balance_report.py @@ -29,78 +29,105 @@ import time import wizard import pooler -report_type = ''' -
-
''' - - -dates_form = ''' -
- - - - - - - -''' - -dates_fields = { - 'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True}, - 'result_selection':{'string':"Display partner ",'type':'selection','selection':[('customer','Debiteur'),('supplier','Creancier'),('all','Tous')]}, - 'soldeinit':{'string':"Inclure les soldes initiaux",'type':'boolean'}, - 'date1': {'string':'Start date', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')}, - 'date2': {'string':'End date', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')}, -} +#report_type = ''' +#
+#
''' +# +# +#dates_form = ''' +#
+# +# +# +# +# +# +# +#''' +# +#dates_fields = { +# 'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True}, +# 'result_selection':{'string':"Display partner ",'type':'selection','selection':[('customer','Debiteur'),('supplier','Creancier'),('all','Tous')]}, +# 'soldeinit':{'string':"Inclure les soldes initiaux",'type':'boolean'}, +# 'date1': {'string':'Start date', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')}, +# 'date2': {'string':'End date', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')}, +#} period_form = ''' -
+ + + + + + + + - + ''' period_fields = { 'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True}, + 'state':{'string':"Select Report Type",'type':'selection','selection':[('none','None'),('bydate','By Date'),('byperiod','By Period')],'default': lambda *a:'none' }, 'fiscalyear': {'string': 'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear', - 'help': 'Keep empty for all open fiscal year'}, - 'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty'}, + 'help': 'Keep empty for all open fiscal year','states':{'none':[('readonly',True)],'bydate':[('readonly',True)]}}, + 'periods': {'string': 'Periods', 'type': 'many2many', 'relation': 'account.period', 'help': 'All periods if empty','states':{'none':[('readonly',True)],'bydate':[('readonly',True)]}}, 'result_selection':{'string':"Display partner",'type':'selection','selection':[('customer','Debiteur'),('supplier','Creancier'),('all','Tous')]}, 'soldeinit':{'string':"Inclure les soldes initiaux",'type':'boolean'}, + 'date1': {'string':'Start date', 'type':'date', 'required':True,'default': lambda *a: time.strftime('%Y-01-01')}, + 'date2': {'string':'End date', 'type':'date', 'required':True,'default': lambda *a: time.strftime('%Y-%m-%d')}, } 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) - + + def _get_load(self,cr,uid,data,context): user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context) if user.company_id: - company_id = user.company_id.id + company_id = user.company_id.id else: - company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0] + company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0] + + fiscalyear_obj = pooler.get_pool(cr.dbname).get('account.fiscalyear') + periods_obj=pooler.get_pool(cr.dbname).get('account.period') + data['form']['fiscalyear'] = fiscalyear_obj.find(cr, uid) + data['form']['periods'] =periods_obj.search(cr, uid, [('fiscalyear_id','=',data['form']['fiscalyear'])]) data['form']['company_id'] = company_id data['form']['soldeinit'] = True data['form']['result_selection'] = 'all' return data['form'] - def _get_defaults_fordate(self, cr, uid, data, context): - user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context) - if user.company_id: - company_id = user.company_id.id - else: - company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0] - data['form']['company_id'] = company_id - data['form']['soldeinit'] = True - data['form']['result_selection'] = 'all' + def _get_defaults(self, cr, uid, data, context): + + if data['form']['state'] == 'none': + return 'report' + else : + if data['form']['state'] == 'byperiod': + data['form']['fiscalyear'] = True + else : + self._check_date(cr, uid, data, context) + data['form']['fiscalyear'] = False + return data['form'] +# def _get_defaults_fordate(self, cr, uid, data, context): +# user = pooler.get_pool(cr.dbname).get('res.users').browse(cr, uid, uid, context=context) +# if user.company_id: +# company_id = user.company_id.id +# else: +# company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0] +# data['form']['company_id'] = company_id +# data['form']['soldeinit'] = True +# data['form']['result_selection'] = 'all' +# return data['form'] + 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']['date1']) cr.execute(sql) @@ -117,24 +144,24 @@ class wizard_report(wizard.interface): states = { 'init': { - 'actions': [], - 'result': {'type':'form', 'arch':report_type,'fields':{}, 'state':[('with_period','Use with Period'),('with_date','Use with Date')]} - }, - 'with_period': { - 'actions': [_get_defaults], - 'result': {'type':'form', 'arch':period_form, 'fields':period_fields, 'state':[('end','Cancel'),('report','Print')]} - }, - 'with_date': { - 'actions': [_get_defaults_fordate], - 'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('checkdate','Print')]} - }, - 'checkdate': { - 'actions': [], - 'result': {'type':'choice','next_state':_check_date} + 'actions': [_get_load], + 'result': {'type':'form', 'arch':period_form, 'fields':period_fields, 'state':[('end','Cancel'),('report','Print')]} }, +# 'with_period': { +# 'actions': [_get_defaults], +# 'result': {'type':'form', 'arch':period_form, 'fields':period_fields, 'state':[('end','Cancel'),('report','Print')]} +# }, +# 'with_date': { +# 'actions': [_get_defaults_fordate], +# 'result': {'type':'form', 'arch':dates_form, 'fields':dates_fields, 'state':[('end','Cancel'),('checkdate','Print')]} +# }, +## 'checkdate': { +## 'actions': [], +## 'result': {'type':'choice','next_state':_check_date} +## }, 'report': { - 'actions': [], + 'actions': [_get_defaults], 'result': {'type':'print', 'report':'account.partner.balance', 'state':'end'} } }