From 834697193539bad42e3fdce16b9fafc4b223f0aa Mon Sep 17 00:00:00 2001 From: apa-tiny Date: Fri, 17 Oct 2008 13:47:41 +0530 Subject: [PATCH] Add partner ledger wizard.... bzr revid: patelamit2003@gmail.com-20081017081741-ne64e0liiraksl4c --- addons/account/report/third_party_ledger.py | 2 +- .../wizard/wizard_third_party_ledger.py | 157 +++++++++++------- 2 files changed, 94 insertions(+), 65 deletions(-) diff --git a/addons/account/report/third_party_ledger.py b/addons/account/report/third_party_ledger.py index c8bda2a3045..aa04279c08d 100755 --- a/addons/account/report/third_party_ledger.py +++ b/addons/account/report/third_party_ledger.py @@ -108,7 +108,7 @@ class third_party_ledger(rml_parse.rml_parse): # Transformation des date # # - if data['form'].has_key('fiscalyear'): + if data['form']['fiscalyear']: self.transform_period_into_date_array(data) else: self.transform_date_into_date_array(data) diff --git a/addons/account/wizard/wizard_third_party_ledger.py b/addons/account/wizard/wizard_third_party_ledger.py index e9f2daf4b01..bd56da71149 100755 --- a/addons/account/wizard/wizard_third_party_ledger.py +++ b/addons/account/wizard/wizard_third_party_ledger.py @@ -30,65 +30,84 @@ import wizard import pooler -report_type = ''' -
-
''' - - -dates_form = ''' -
- - - - - - - - - - -''' - -dates_fields = { - 'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True}, - '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')}, - 'result_selection':{'string':"Display partners",'type':'selection','selection':[('customer','Debiteur'),('supplier','Creancier'),('all','Tous')]}, - 'soldeinit':{'string':"Inclure les soldes initiaux",'type':'boolean'}, - 'reconcil':{'string':"Inclure les ecritures reconsiliees",'type':'boolean'}, - 'page_split':{'string':"Un partenaire par page",'type':'boolean'}, -} +#report_type = ''' +#
+#
''' +# +# +#dates_form = ''' +#
+# +# +# +# +# +# +# +# +# +# +#''' +# +#dates_fields = { +# 'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True}, +# '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')}, +# 'result_selection':{'string':"Display partners",'type':'selection','selection':[('customer','Debiteur'),('supplier','Creancier'),('all','Tous')]}, +# 'soldeinit':{'string':"Inclure les soldes initiaux",'type':'boolean'}, +# 'reconcil':{'string':"Inclure les ecritures reconsiliees",'type':'boolean'}, +# 'page_split':{'string':"Un partenaire par page",'type':'boolean'}, +#} period_form = '''
- + + + + + + + + - - + + + + - + + + + + + + + + - + ''' period_fields = { - 'company_id': {'string': 'Company', 'type': 'many2one', 'relation': 'res.company', 'required': True}, + 'company_id': {'string': ' Company', 'type': 'many2one', 'relation': 'res.company', 'required': True}, + 'state':{'string':"Report Type",'type':'selection','selection':[('bydate','By Date'),('byperiod','By Period')],'default': lambda *a:'byperiod' }, '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'}, - 'result_selection':{'string':"Display partners",'type':'selection','selection':[('customer','Debiteur'),('supplier','Creancier'),('all','Tous')]}, + 'result_selection':{'string':" Partners",'type':'selection','selection':[('customer','Debiteur'),('supplier','Creancier'),('all','Tous')]}, 'soldeinit':{'string':"Inclure les soldes initiaux",'type':'boolean'}, - 'reconcil':{'string':"Inclure les ecritures reconsiliees",'type':'boolean'}, + 'reconcil':{'string':" Inclure les ecritures reconsiliees",'type':'boolean'}, 'page_split':{'string':"Un partenaire par page",'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) data['form']['display_account']='bal_all' @@ -100,26 +119,15 @@ class wizard_report(wizard.interface): else: company_id = pooler.get_pool(cr.dbname).get('res.company').search(cr, uid, [('parent_id', '=', False)])[0] data['form']['company_id'] = company_id + periods_obj=pooler.get_pool(cr.dbname).get('account.period') + data['form']['periods'] =periods_obj.search(cr, uid, [('fiscalyear_id','=',data['form']['fiscalyear'])]) data['form']['page_split'] = False data['form']['reconcil'] = False data['form']['soldeinit'] = True return data['form'] - def _get_defaults_fordate(self, cr, uid, data, context): - data['form']['result_selection'] = 'all' - 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']['page_split'] = False - data['form']['reconcil'] = False - data['form']['soldeinit'] = True - 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) @@ -132,27 +140,48 @@ class wizard_report(wizard.interface): else: raise wizard.except_wizard('UserError','Date not in a defined fiscal year') + + + def _check_state(self, cr, uid, data, context): + 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): +# data['form']['result_selection'] = 'all' +# 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']['page_split'] = False +# data['form']['reconcil'] = False +# data['form']['soldeinit'] = True +# return data['form'] 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} - }, +# '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': [_check_state], 'result': {'type':'print', 'report':'account.third_party_ledger', 'state':'end'} } }