from reportlab.graphics.shapes import Drawing
from reportlab.graphics.charts.barcharts import VerticalBarChart
import reportlab.lib.colors as colors
+#from reportlab.graphics.widgetbase import Widget, TypedPropertyCollection
+#from reportlab.graphics.charts.textlabels import BarChartLabel
#from reportlab.graphics import renderPM
import tools
'lines':self.lines,
})
self.count=0
+ self.list=[]
def lines(self,data):
res={}
result=[]
- obj_ind=self.pool.get('account.report.report').browse(self.cr,self.uid,data['indicator_id'])
- res = {
- 'name':obj_ind.name,
- 'code':obj_ind.code,
- 'expression':obj_ind.expression,
- 'disp_graph':obj_ind.disp_graph,
- 'note':obj_ind.note,
- 'type':obj_ind.type
- }
- result.append(res)
+ obj_inds=self.pool.get('account.report.report').browse(self.cr,self.uid,data['indicator_id'])
+ def find_child(obj):
+ self.list.append(obj)
+ if obj.child_ids:
+ for child in obj.child_ids:
+ find_child(child)
+ return True
+ find_child(obj_inds)
+
+ for obj_ind in self.list:
+ res = {
+ 'id':obj_ind.id,
+ 'name':obj_ind.name,
+ 'code':obj_ind.code,
+ 'expression':obj_ind.expression,
+ 'disp_graph':obj_ind.disp_graph,
+ 'note':obj_ind.note,
+ 'type':obj_ind.type
+ }
+ result.append(res)
return result
- def test1(self):
+ def test1(self,data,object):
+ path=tools.config['root_path']+"/Temp_report/Image"
+ obj_history=self.pool.get('account.report.history')
+
+ if data['select_base']=='year':
+ tuple_search=('fiscalyear_id','in',data['base_selection'][0][2])
+ else:
+ tuple_search=('period_id','in',data['base_selection'][0][2])
+
+ history_ids=obj_history.search(self.cr,self.uid,[('name','=',object['id']),tuple_search])
+ obj_his=obj_history.browse(self.cr,self.uid,history_ids)
+
+ data_val=[]
+ data_period=[]
+ for item in obj_his:
+ data_val.append(item.val)
+ data_period.append(item.period_id.name)
self.count +=1
- drawing = Drawing(400, 200)
+ drawing = Drawing(400, 300)
data = [
- (13, 5, 20, 22, 37, 45, 19, 4,11,-5),
+ tuple(data_val),
]
+ value_min=0.0
+ vmin=min(data_val)
+ vmax=max(data_val)
+
+ val_min=((vmin < 0.00 and vmin-2.00) or 0.00)
+ # calculating maximum
+ val_max=(vmax/(pow(10,len(str(int(vmax)))-2))+1)*pow(10,len(str(int(vmax)))-2)
bc = VerticalBarChart()
bc.x = 50
bc.y = 50
- bc.height = 155
+ bc.height = 245
bc.width = 300
bc.data = data
+ value_step=(abs(val_max)-abs(val_min))/5
+
bc.strokeColor = colors.black
- bc.valueAxis.valueMin = 0
- bc.valueAxis.valueMax = 50
- bc.valueAxis.valueStep = 10
+ bc.valueAxis.valueMin = val_min
+ bc.valueAxis.valueMax = val_max
+ bc.valueAxis.valueStep = value_step
bc.categoryAxis.labels.boxAnchor = 'ne'
bc.categoryAxis.labels.dx = 8
-# bc.barWidth=5
+
bc.categoryAxis.labels.dy = -2
bc.categoryAxis.labels.angle = 30
- bc.categoryAxis.categoryNames = ['Jan-99','Feb-99','Mar-99',
- 'Apr-99','May-99','Jun-99','Jul-99','Aug-99','kkk','fff']
+ bc.categoryAxis.categoryNames = data_period
drawing.add(bc)
- drawing.save(formats=['png'],fnRoot=tools.config['root_path']+"/Temp_report/Image"+str(self.count),title="helo")
+ drawing.save(formats=['png'],fnRoot=path+str(self.count),title="helo")
# renderPM.drawToFile(drawing1, 'example1.jpg','jpg')
- return tools.config['root_path']+"/Temp_report/Image"+str(self.count)+'.png'
+ return path+str(self.count)+'.png'
report_sxw.report_sxw('report.print.indicators', 'account.report.history',