partner balance wizard completed.....
bzr revid: patelamit2003@gmail.com-20081017130439-a0dp1ep4u7q6flf5
This commit is contained in:
parent
9f66c83115
commit
c873b82e05
|
@ -67,10 +67,13 @@ class partner_balance(report_sxw.rml_parse):
|
|||
return full_str_date
|
||||
|
||||
#
|
||||
|
||||
|
||||
def transform_period_into_date_array(self,data):
|
||||
## Get All Period Date
|
||||
#
|
||||
# If we have no period we will take all perdio in the FiscalYear.
|
||||
print"data['form']['periods'][0][2]",data['form']['periods'][0][2]
|
||||
if not data['form']['periods'][0][2] :
|
||||
periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',data['form']['fiscalyear'])])
|
||||
else:
|
||||
|
@ -79,18 +82,63 @@ class partner_balance(report_sxw.rml_parse):
|
|||
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,data):
|
||||
|
||||
return_array = self.date_range(data['form']['date1'],data['form']['date2'])
|
||||
self.date_lst = return_array
|
||||
self.date_lst.sort()
|
||||
|
||||
|
||||
def transform_both_into_date_array(self,data):
|
||||
if not data['form']['periods'][0][2] :
|
||||
periods_id = self.pool.get('account.period').search(self.cr, self.uid, [('fiscalyear_id','=',data['form']['fiscalyear'])])
|
||||
else:
|
||||
periods_id = data['form']['periods'][0][2]
|
||||
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)
|
||||
|
||||
period_start_date = date_array[0]
|
||||
date_start_date = data['form']['date1']
|
||||
period_stop_date = date_array[-1]
|
||||
date_stop_date = data['form']['date2']
|
||||
|
||||
if period_start_date<date_start_date:
|
||||
start_date = period_start_date
|
||||
else :
|
||||
start_date = date_start_date
|
||||
|
||||
if date_stop_date<period_stop_date:
|
||||
stop_date = period_stop_date
|
||||
else :
|
||||
stop_date = date_stop_date
|
||||
|
||||
print"===start_date===",start_date
|
||||
print"===stop_date===",stop_date
|
||||
final_date_array = []
|
||||
final_date_array = final_date_array + self.date_range(start_date,stop_date)
|
||||
self.date_lst = final_date_array
|
||||
self.date_lst.sort()
|
||||
|
||||
def transform_none_into_date_array(self,data):
|
||||
print"======transform_none_into_date_array====="
|
||||
sql = "SELECT min(date) as start_date from account_move_line"
|
||||
self.cr.execute(sql)
|
||||
start_date = self.cr.fetchone()[0]
|
||||
|
||||
sql = "SELECT max(date) as start_date from account_move_line"
|
||||
self.cr.execute(sql)
|
||||
stop_date = self.cr.fetchone()[0]
|
||||
print"stop_date",stop_date
|
||||
|
||||
array = []
|
||||
array = array + self.date_range(start_date,stop_date)
|
||||
self.date_lst = array
|
||||
self.date_lst.sort()
|
||||
|
||||
|
||||
def comma_me(self,amount):
|
||||
if type(amount) is float :
|
||||
|
@ -110,13 +158,27 @@ class partner_balance(report_sxw.rml_parse):
|
|||
# Transformation des date
|
||||
#
|
||||
#
|
||||
|
||||
if data['form']['fiscalyear']:
|
||||
print"data['form']['fiscalyear']=True"
|
||||
self.transform_period_into_date_array(data)
|
||||
else:
|
||||
print"data['form']['fiscalyear']=False"
|
||||
if data['form']['state'] == 'none':
|
||||
print"========none=========="
|
||||
self.transform_none_into_date_array(data)
|
||||
if data['form']['state'] == 'bydate':
|
||||
print"========bydate=========="
|
||||
self.transform_date_into_date_array(data)
|
||||
if data['form']['state'] == 'byperiod':
|
||||
print"========byperiod=========="
|
||||
self.transform_period_into_date_array(data)
|
||||
if data['form']['state'] == 'all':
|
||||
print"========both=========="
|
||||
self.transform_both_into_date_array(data)
|
||||
|
||||
|
||||
|
||||
# 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)) + '\''
|
||||
## Compute Code
|
||||
|
@ -151,6 +213,7 @@ class partner_balance(report_sxw.rml_parse):
|
|||
#
|
||||
#
|
||||
if data['form']['soldeinit'] :
|
||||
print"=====self.date_lst[0]=====",self.date_lst[0]
|
||||
self.cr.execute(
|
||||
"SELECT p.ref, p.name,l.account_id,ac.name as account_name,ac.code as code , sum(debit) as debit, sum(credit) as credit, " \
|
||||
"CASE WHEN sum(debit) > sum(credit) " \
|
||||
|
@ -182,6 +245,7 @@ class partner_balance(report_sxw.rml_parse):
|
|||
#
|
||||
#
|
||||
#
|
||||
|
||||
self.cr.execute(
|
||||
"SELECT p.ref,l.account_id,ac.name as account_name,ac.code as code ,p.name, sum(debit) as debit, sum(credit) as credit, " \
|
||||
"CASE WHEN sum(debit) > sum(credit) " \
|
||||
|
|
|
@ -30,7 +30,7 @@ import wizard
|
|||
import pooler
|
||||
|
||||
period_form = '''<?xml version="1.0"?>
|
||||
<form string="Select period">
|
||||
<form string="Select period" colspan="4">
|
||||
<field name="company_id"/>
|
||||
<field name="result_selection"/>
|
||||
<newline/>
|
||||
|
@ -41,13 +41,13 @@ period_form = '''<?xml version="1.0"?>
|
|||
<field name="state" required="True"/>
|
||||
<newline/>
|
||||
<group colspan="4">
|
||||
<group attrs="{'invisible':[('state','=','byperiod')]}" colspan="2">
|
||||
<group attrs="{'invisible':[('state','=','byperiod'),('state','=','none')]}" colspan="2">
|
||||
<separator string="Date Filter" colspan="4"/>
|
||||
<field name="date1"/>
|
||||
<newline/>
|
||||
<field name="date2"/>
|
||||
</group>
|
||||
<group attrs="{'invisible':[('state','=','bydate')]}" colspan="2">
|
||||
<group attrs="{'invisible':[('state','=','bydate'),('state','=','none')]}" colspan="2">
|
||||
<separator string="Filter on Periods" colspan="4"/>
|
||||
<field name="periods" colspan="4" nolabel="1"/>
|
||||
</group>
|
||||
|
@ -60,7 +60,7 @@ period_fields = {
|
|||
'string':"Date/Period Filter",
|
||||
'type':'selection',
|
||||
'selection':[('bydate','By Date'),('byperiod','By Period'),('all','By Date and Period'),('none','No Filter')],
|
||||
'default': lambda *a:'none'
|
||||
'default': lambda *a:'byperiod'
|
||||
},
|
||||
'fiscalyear': {
|
||||
'string':'Fiscal year', 'type': 'many2one', 'relation': 'account.fiscalyear',
|
||||
|
@ -98,12 +98,8 @@ class wizard_report(wizard.interface):
|
|||
|
||||
def _check_state(self, cr, uid, data, context):
|
||||
|
||||
if data['form']['state'] == 'byperiod':
|
||||
data['form']['fiscalyear'] = True
|
||||
else :
|
||||
if data['form']['state'] == 'bydate' :
|
||||
self._check_date(cr, uid, data, context)
|
||||
data['form']['fiscalyear'] = False
|
||||
|
||||
return data['form']
|
||||
|
||||
def _check_date(self, cr, uid, data, context):
|
||||
|
|
Loading…
Reference in New Issue