1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
row_xml = { 'month' : [], 'ending' : [] }
for key, row in rows:
if key != 'ending':
tkey = 'month'
row_xml[tkey].append('<row monthYear="%s">' % (ym_desc[key]))
else:
tkey = 'ending'
row_xml[tkey].append('<row>')
for code in ores['prim']:
row_xml[tkey].append('<qty value="%s"/>' % (row['vol']['prim'].get(code,0)))
row_xml[tkey].append('<qty value="%s"/>' % (row['vol']['prim']['total']))
for code in ores['sec']:
row_xml[tkey].append('<qty value="%s"/>' % (row['vol']['sec'].get(code,0)))
row_xml[tkey].append('<qty value="%s"/>' % (row['vol']['sec']['total']))
row_xml[tkey].append('<qty value="%s"/>' % (row['vol']['total']))
for code in ores['prim']:
row_xml[tkey].append('<qty value="%s"/>' % (row['ton']['prim'].get(code,0)))
row_xml[tkey].append('<qty value="%s"/>' % (row['ton']['prim']['total']))
for code in ores['sec']:
row_xml[tkey].append('<qty value="%s"/>' % (row['ton']['sec'].get(code,0)))
row_xml[tkey].append('<qty value="%s"/>' % (row['ton']['sec']['total']))
row_xml[tkey].append('<qty value="%s"/>' % (row['ton']['total']))
row_xml[tkey].append('</row>')
lines_xml = u'''
<lines>
<colWidths>%s</colWidths>
%s
</lines>''' % (colWidths, "\n".join([x.decode('utf-8') for x in row_xml['month'] ]))
tablef_xml = u'''
<table-footer>
<colWidths>%s</colWidths>
%s
</table-footer>''' % (colWidths, "\n".join(row_xml['ending']))
xml = u'''<?xml version="1.0" ?>
<report>
<report-title>Manipulés mensuel</report-title>
<table-header1>
<colWidths>20mm,130mm,130mm</colWidths>
<field>Volume</field>
<field>Tonne</field>
</table-header1>
<table-header2>
<colWidths>20mm,60mm,60mm,10mm,60mm,60mm,10mm</colWidths>
<field>Manipulé primaire</field>
<field>Manipulé secondaire</field>
</table-header2>
%s
%s
%s
</report>
''' % (tableh_xml, lines_xml, tablef_xml)
return self.post_process_xml_data(cr, uid, xml, context)
report_custom('report.monthly.manipulated', 'cftmc.production.data', '', './cftmc_production/report/monthly_manipulated.xsl')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
Partager