[IMP]:Improved print screen report with group by.
bzr revid: apa@tinyerp.com-20100216083952-wxdnu5abf0qy01wt
This commit is contained in:
parent
810ae047dc
commit
4898b74704
|
@ -92,7 +92,7 @@
|
|||
<xsl:value-of select="."/>
|
||||
</font></para>
|
||||
</xsl:when>
|
||||
|
||||
|
||||
<xsl:otherwise>
|
||||
<para>
|
||||
<font fontName="Helvetica" fontSize="9">
|
||||
|
@ -102,6 +102,32 @@
|
|||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:when test="@para='group'">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@tree='yes'">
|
||||
<para>
|
||||
<xsl:attribute name="leftIndent"><xsl:value-of select="@space"/></xsl:attribute>
|
||||
<font fontName="Helvetica-bold" fontSize="9">
|
||||
<xsl:value-of select="."/>
|
||||
</font>
|
||||
</para>
|
||||
</xsl:when>
|
||||
<xsl:when test="@tree='float'">
|
||||
<para style="float_right"><font fontName="Helvetica-bold" fontSize="9">
|
||||
<xsl:value-of select="."/>
|
||||
</font></para>
|
||||
</xsl:when>
|
||||
|
||||
<xsl:otherwise>
|
||||
<para>
|
||||
<font fontName="Helvetica-bold" fontSize="9">
|
||||
<xsl:value-of select="."/>
|
||||
</font>
|
||||
</para>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xpre>
|
||||
<xsl:value-of select="."/>
|
||||
|
|
|
@ -71,14 +71,31 @@ class report_printscreen_list(report_int):
|
|||
fields_order = self._parse_string(result['arch'])
|
||||
rows = model.read(cr, uid, datas['ids'], result['fields'].keys(), context)
|
||||
ids2 = [x['id'] for x in rows] # getting the ids from read result
|
||||
|
||||
if datas['ids'] != ids2: # sorted ids were not taken into consideration for print screen
|
||||
rows_new = []
|
||||
for id in datas['ids']:
|
||||
element = [elem for elem in rows if elem['id']==id]
|
||||
rows_new.append(element[0])
|
||||
rows = rows_new
|
||||
|
||||
if context.get('group_by',False):
|
||||
fields_order.remove(context['group_by'])
|
||||
fields_order.insert(0, context['group_by'])
|
||||
re = model.read_group(cr, uid, [], fields_order, context.get('group_by',False),0,None,context)
|
||||
rows=[]
|
||||
for r in re:
|
||||
for f in fields_order:
|
||||
if f not in r:
|
||||
r.update({f:False})
|
||||
if result['fields'][f]['type']=='many2one' and r[f]:
|
||||
r.update({f:(r['__domain'][0][2],r[r['__domain'][0][0]])})
|
||||
if result['fields'][f]['type'] == 'date' and r[f]:
|
||||
r[f] = ''
|
||||
r['__group']=True
|
||||
rows.append(r)
|
||||
_ids = model.search(cr, uid, r['__domain'])
|
||||
res=model.read(cr, uid, _ids, result['fields'].keys(), context)
|
||||
for r in res:
|
||||
rows.append(r)
|
||||
res = self._create_table(uid, datas['ids'], result['fields'], fields_order, rows, context, model_desc)
|
||||
return (self.obj.get(), 'pdf')
|
||||
|
||||
|
@ -182,8 +199,10 @@ class report_printscreen_list(report_int):
|
|||
d1 = datetime.strptime(line[f], '%Y-%m-%d %H:%M:%S')
|
||||
new_d1 = d1.strftime(format)
|
||||
line[f] = new_d1
|
||||
|
||||
col = etree.SubElement(node_line, 'col', para='yes', tree='no')
|
||||
if line.get('__group'):
|
||||
col = etree.SubElement(node_line, 'col', para='group', tree='no')
|
||||
else:
|
||||
col = etree.SubElement(node_line, 'col', para='yes', tree='no')
|
||||
if line[f] != None:
|
||||
col.text = tools.ustr(line[f] or '')
|
||||
if float_flag:
|
||||
|
@ -215,7 +234,6 @@ class report_printscreen_list(report_int):
|
|||
etree.parse(os.path.join(tools.config['root_path'],
|
||||
'addons/base/report/custom_new.xsl')))
|
||||
rml = etree.tostring(transform(new_doc))
|
||||
|
||||
self.obj = render.rml(rml, title=self.title)
|
||||
self.obj.render()
|
||||
return True
|
||||
|
|
Loading…
Reference in New Issue