[IMP]:improved for pagecount

bzr revid: apa@tinyerp.com-20101005072709-y8sl7zq4ctxcgryn
This commit is contained in:
apa-tiny 2010-10-05 12:57:09 +05:30
parent 7ff12c0751
commit c841c95c39
4 changed files with 13 additions and 7 deletions

View File

@ -9,8 +9,6 @@
<drawString x="1.3cm" y="19.5cm"><xsl:value-of select="//header-date"/></drawString>
<setFont name="DejaVu Sans Bold" size="10"/>
<drawString x="13.8cm" y="19.5cm"><xsl:value-of select="//company"/></drawString>
<setFont name="DejaVu Sans" size="8"/>
<drawRightString x="28.4cm" y="19.5cm"><pageNumber/> / </drawRightString>
<stroke color="#000000"/>
<lines size="8">1.3cm 19.3cm 28.5cm 19.3cm</lines>
</xsl:template>

View File

@ -174,6 +174,8 @@ class report_rml(report_int):
return xml
def create_pdf(self, rml, localcontext = None, logo=None, title=None):
if not localcontext:
localcontext={'header':False}
if logo:
self.bin_datas['logo'] = logo
else:

View File

@ -68,8 +68,8 @@ class NumberedCanvas(canvas.Canvas):
while not self.pages.get(key,False):
key = key + 1
self.setFont("Helvetica", 8)
self.drawRightString((self._pagesize[0]-35), (self._pagesize[1]-40),
"%(this)i / %(total)i" % {
self.drawRightString((self._pagesize[0]-35), (self._pagesize[1]-43),
"Page %(this)i of %(total)i" % {
'this': self._pageNumber+1,
'total': self.pages.get(key,False),
}
@ -820,9 +820,12 @@ class TinyDocTemplate(platypus.BaseDocTemplate):
class _rml_template(object):
def __init__(self, localcontext, out, node, doc, images={}, path='.', title=None):
self.localcontext = localcontext
if not self.localcontext:
self.localcontext={'header':'internal'}
self.images= images
self.path = path
self.title = title
if not node.get('pageSize'):
pageSize = (utils.unit_get('21cm'), utils.unit_get('29.7cm'))
else:
@ -848,7 +851,7 @@ class _rml_template(object):
except Exception: # FIXME: be even more specific, perhaps?
gr=''
if len(gr):
self.image=[ n for n in utils._child_get(gr[0], self) if n.tag=='image' or not self.localcontext]
# self.image=[ n for n in utils._child_get(gr[0], self) if n.tag=='image' or not self.localcontext]
drw = _rml_draw(self.localcontext,gr[0], self.doc, images=images, path=self.path, title=self.title)
self.page_templates.append( platypus.PageTemplate(frames=frames, onPage=drw.render, **utils.attr_get(pt, [], {'id':'str'}) ))
else:
@ -866,12 +869,14 @@ class _rml_template(object):
fis += r.render(node_story)
# Reset Page Number with new story tag
fis.append(PageReset())
if not self.image:
if self.localcontext and self.localcontext.get('header',False) and \
(self.localcontext['header']=='internal' or self.localcontext['header']=='internal landscape'):
self.doc_tmpl.afterFlowable(fis)
story_cnt += 1
if self.localcontext:
fis.append(PageCount())
if not self.image:
if self.localcontext and self.localcontext.get('header',False) and \
(self.localcontext['header']=='internal' or self.localcontext['header']=='internal landscape'):
self.doc_tmpl.build(fis,canvasmaker=NumberedCanvas)
else:
self.doc_tmpl.build(fis)

View File

@ -360,6 +360,7 @@ class report_sxw(report_rml, preprocess.report):
return table_obj.browse(cr, uid, ids, list_class=browse_record_list, context=context, fields_process=_fields_process)
def create(self, cr, uid, ids, data, context=None):
context.update({'header':self.header})
pool = pooler.get_pool(cr.dbname)
ir_obj = pool.get('ir.actions.report.xml')
report_xml_ids = ir_obj.search(cr, uid,