亲爱的,
我们要求仅在 PDF 上的业务文档(例如发票、销售报价单、销售订单)的第一页上打印用户定义的公司抬头。PDF 报告的所有其他页面必须只包含我们的公司徽标。
幸运地找到了Brett Lehrer 的帖子我试图用
<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">
...
<!-- all corporate contact data in here -->
...
</docIf>
</pageGraphics>
</pageTemplate>
</header>
在自定义公司标题 RML 定义中。
进一步修改./odoo/openerp/report/render/rml2pdf/trml2pdf.py
函数中的文件def _flowable(...)
以处理<docIf>
标签如下
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
但这并没有带来所需的结果:
公司页眉打印在 PDF 上,每页<docIf>
标签内没有任何定义。似乎条件永远不会变为 True。
几天来的网络研究现在没有结果。
你们中的任何人可能已经解决了这样的需求或在 OpenERP/odoo 中使用条件 RML 输出?
你能帮忙吗?非常感谢您的评论/想法。谢谢