1

我在模块上创建报告account.invoice,我尝试显示一些数据表单sale.order 但在account.invoice表中没有order_id(id 相关)如果我想sale.orderaccount.invoice报告上显示一些数据表单但没有相关的 id我该怎么办sale.order

所以,如果account.invoiceorder_id(id 相关)我可以使用

[[o.order_id._____]]

有人可以给我一些建议吗?

这是我的代码

class order(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context=None):
        super(order,self).__init__(cr, uid, name, context=context)
        so_origin = self.pool.get('account.invoice').browse(cr, uid, uid)
        so_obj = self.pool.get('sale.order').browse(cr, uid, so_origin.id)
        self.localcontext.update({
                'order_id': so_obj.id
        })

并在 rml 文件中

[[repeatIn(objects,'o')]]
[[o.order_id._______]]
4

1 回答 1

2

只需编写一个设置销售订单browse_record的方法,以便您可以正常使用它。

class invoice_parser(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context=None):
        super(invoice_parser,self).__init__(cr, uid, name, context=context)
        self.order = False

        def setOrder(invoice_id):
            self.order = False
            so_obj = self.pool.get('sale.order')
            so_list = so_obj.search(cr, uid, [('invoice_ids.id','=',invoice_id)], context=context)
            # big question: what should be done with more than one sale order found
            # easiest solution: return True only when one was found
            if len(so_list) == 1:
                self.order = so_obj.browse(cr, uid, so_list[0], context)
                return True
            else:
                return False

        def getOrder():
            return self.order

        self.localcontext.update({
                'setOrder': setOrder,
                'getOrder': getOrder,
        })

现在您可以使用:

[[ setOrder(o.id) and getOrder().name or ' ']]

或者你想做的任何事情。

于 2014-04-02T06:32:20.653 回答