python - Conditional Corporate RML Header with docIf -
dears,
we have request print user defined corporate header on first page of business document on pdf (such invoice, sales quotation, sales order). other pages of pdf reports must contain our corporate logo.
lucky find post of brett lehrer tried achieve using
<header> <pagetemplate> <frame id="first" x1="1.3cm" y1="3.0cm" height="21.7cm" width="19.0cm"/> <stylesheet> <!-- style definitions in here --> </stylesheet> <pagegraphics> ... <!-- corporate logo definition in here --> ... <docif cond="doc.page==1"> ... <!-- corporate contact data in here --> ... </docif> </pagegraphics> </pagetemplate> </header>
in custom corporate header rml definition.
further modified file ./odoo/openerp/report/render/rml2pdf/trml2pdf.py
in function def _flowable(...)
handle <docif>
tag follows
elif node.tag == 'hr': width_hr=node.get('width') or '100%' color_hr=node.get('color') or 'black' thickness_hr=node.get('thickness') or 1 linecap_hr=node.get('linecap') or 'round' return platypus.flowables.hrflowable(width=width_hr,color=color.get(color_hr),thickness=float(thickness_hr),linecap=str(linecap_hr)) ##### edit-start #### elif node.tag == 'docif': return platypus.flowables.docif(node.get('cond'), self.render(node)) ##### edit-end #### else: sys.stderr.write('warning: flowable not yet implemented: %s !\n' % (node.tag,)) return none
but brought not required result:
the corporate header prints on pdf without of definitions inside <docif>
tags on every page. seems if condition never becomes true.
web research days brought no result.
anyone of might solved such demand or played conditional rml output in openerp/odoo?
can help, please? comments/ideas highly appreciated. thanks
i comment, i'm not allowed. ^^ think it's not possible use docif page numbers change layout, because rml processes page numbers 1 of last steps. (i guess?!) tried , didn't work.
long story short had same problem. solved way. link
as long want change first page should work.
mfg
Comments
Post a Comment