OpenERP v7 报告错误

0 投票
1 回答
1041 浏览
提问于 2025-05-01 05:51

我在 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 个回答

2

声明应该像这样

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

撰写回答