Python 在openerp RML中将销售订单信息添加到发票

Python 在openerp RML中将销售订单信息添加到发票,python,openerp,rml,Python,Openerp,Rml,在我的销售订单中,我有一个需要在客户发票中引用的客户参考号,发票使用源文档搜索其相关的销售订单,然后搜索销售记录。我的RML中包含以下内容: [[o.getcustomerPO(origin) or 'No associated PO' ]] 在我的解析器中: def getcustomerPO(self,so_num): context = {} saleorder = self.pool.get('sale.order') sale_oID = saleorder.search(s

在我的销售订单中,我有一个需要在客户发票中引用的客户参考号,发票使用源文档搜索其相关的销售订单,然后搜索销售记录。我的RML中包含以下内容:

[[o.getcustomerPO(origin) or 'No associated PO' ]]
在我的解析器中:

    def getcustomerPO(self,so_num):
context = {}
saleorder = self.pool.get('sale.order')
sale_oID = saleorder.search(self.cr, self.uid,[('name','=','so_num')],context=context)
customerPO = saleorder.browse(self.cr, self.uid, sale_oID, context=context)
return customerPO
但是没有骰子


我不确定如何继续。

我不知道您是否使用该函数更新本地上下文:

self.localcontext.update({
            'time': time,
            'getcustomerPO': self.getcustomerPO,
        })
在rml中,应该是这样的:

[[ getcustomerPO(origin) or 'No associated PO' ]]
还有一件事,在本报告中,布尔值被勾选为“从附件重新加载”。这意味着,当您第二次打印报告时,它将显示上一份报告。因此,您还需要通过添加以下属性从report.xml文件中取消勾选该布尔值:

attachment_use="True"
谢谢。

试试看

[[getcustomerPO(o.origin) or 'No associated PO' ]]

附件_use=“true”可以,因为它只能打印一次,如果更改,他们可以删除所附发票以更新为最新发票。我不确定我应该把self.localcontext.update.edit放在哪里:nvr mind在最后的评论上,我只是没有看。。。仍然没有运气,但是请检查您的函数是否得到调用。请通过在init函数中添加print语句来检查它。我有以下作为init函数的“code”类account\u invoice(report\u sxw.rml\u parse):def\u init\u(self,cr,uid,name,context):super(account\u invoice,self)。\u init\u(cr,uid,name,context=context)打印“localcontext”self.localcontext.update({'time':time,'getcustomerPO':self.getcustomerPO,})但我没有收到任何打印声明我认为您做错了..请向我们展示调用新报表的xml代码以及如何调用报表解析器。调用解析器:[[getcustomerPO(o)或“无关联PO”]]