OpenERP v7报告错误

时间:2014-11-03 04:29:58

标签: python xml openerp odoo rml

我在stock模块上添加了一个新报告(进入OpenERP v7),但是当我点击“打印”按钮时,rml文件的路径对我来说是正确的:

RML is not available at specified location or not enough data to print!

(None, None, None)

我在.py文件中指定的路径中应该是错误,但我检查并重新检查并且看起来是正确的。

这是我的代码:

import time
from openerp.report import report_sxw

class reporte_locacion(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context):
        super(reporte_locacion, self).__init__(cr, uid, name, context=context)
        self.localcontext.update({
             'time': time,
             'qty_total':self._qty_total
        })

def _qty_total(self, objects):
    total = 0.0
    uom = objects[0].product_uom.name
    for obj in objects:
        total += obj.product_qty
    return {'quantity':total,'uom':uom}

report_sxw.report_sxw(
    'report.reporte.locacion',
    'product.product',
    'addons/stock/report/reporte_locacion.rml',
    parser=reporte_locacion,
    header='internal'
)

我已经在那个位置上了,可能是stock_report.xml文件吗?

以下是我如何申报报告:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <report auto="False" id="reporte_locacion" model="product.product" name="reporte.locacion" string="Productos en almacen"/>
        <report auto="False" id="report_product_history" model="product.product" name="stock.product.history" string="Stock Level Forecast"/>
        <report id="report_picking_list" model="stock.picking" name="stock.picking.list" string="Picking Slip" rml="stock/report/picking.rml"/>
        <report id="report_picking_list_in" model="stock.picking.in" name="stock.picking.list.in" string="Receipt Slip" rml="stock/report/picking.rml"/>
        <report id="report_picking_list_out" model="stock.picking.out" name="stock.picking.list.out" string="Delivery Slip" rml="stock/report/picking.rml"/>
        <report id="report_move_labels" model="stock.move" name="stock.move.label" string="Item Labels" xml="stock/report/lot_move_label.xml" xsl="stock/report/lot_move_label.xsl"/>
        <report auto="False"  id="report_location_overview" model="stock.location" name="lot.stock.overview" string="Location Inventory Overview" rml="stock/report/lot_overview.rml"/>
        <report id="report_location_overview_all" model="stock.location" name="lot.stock.overview_all" string="Location Content" rml="stock/report/lot_overview_all.rml"/>
        <report id="report_stock_inventory_move" model="stock.inventory" name="stock.inventory.move" string="Stock Inventory" rml="stock/report/stock_inventory_move.rml"/>
    </data>
</openerp>

关于它的第一个报告是有错误的那个,我在那里错过了吗?

应该没问题,因为它与其他报告的声明类型几乎相同,但它们都可以正常工作。

有什么想法吗?

提前致谢!

1 个答案:

答案 0 :(得分:2)

宣言应该是这样的

<report id="reporte_locacion" 
        model="product.product" 
        name="reporte.locacion" 
        string="Productos en almacen" 
        rml="addons/stock/report/reporte_locacion.rml"/>