Add partner ledger wizard....

bzr revid: patelamit2003@gmail.com-20081017081741-ne64e0liiraksl4c
This commit is contained in:
apa-tiny 2008-10-17 13:47:41 +05:30
parent 89777aeaeb
commit 8346971935
2 changed files with 94 additions and 65 deletions

View File

@ -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)

View File

@ -30,65 +30,84 @@ import wizard
import pooler
report_type = '''<?xml version="1.0"?>
<form string="Select Report Type">
</form>'''
dates_form = '''<?xml version="1.0"?>
<form string="Select period">
<field name="company_id" colspan="4"/>
<newline/>
<field name="date1"/>
<field name="date2"/>
<newline/>
<field name="result_selection"/>
<field name="soldeinit"/>
<field name="reconcil"/>
<newline/>
<field name="page_split"/>
</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 = '''<?xml version="1.0"?>
#<form string="Select Report Type">
#</form>'''
#
#
#dates_form = '''<?xml version="1.0"?>
#<form string="Select period">
# <field name="company_id" colspan="4"/>
# <newline/>
# <field name="date1"/>
# <field name="date2"/>
# <newline/>
# <field name="result_selection"/>
# <field name="soldeinit"/>
# <field name="reconcil"/>
# <newline/>
# <field name="page_split"/>
#</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 = '''<?xml version="1.0"?>
<form string="Select period">
<field name="company_id" colspan="4"/>
<group colspan = "4" >
<field name="company_id" colspan = "4"/>
</group>
<group colspan = "4" >
<field name="state" required="True"/>
</group>
<newline/>
<field name="fiscalyear" colspan="4"/>
<field name="periods" colspan="4"/>
<group attrs="{'invisible':[('state','=','byperiod')]}" colspan = "4">
<field name="date1"/>
<field name="date2"/>
</group>
<newline/>
<field name="result_selection"/>
<group attrs="{'invisible':[('state','=','bydate')]}" colspan = "4">
<field name="fiscalyear" colspan = "4"/>
<field name="periods" colspan = "4"/>
</group>
<group colspan = "4" >
<field name="result_selection"/>
<field name="soldeinit"/>
</group>
<group colspan = "4" >
<field name="reconcil"/>
<newline/>
<field name="page_split"/>
</group>
</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'}
}
}