0
我正在做一個新的報告,從OpenOffice base_report_designer
模塊,在product
對象。報告問題在OpenERP v7
一切似乎都不錯,但每次我嘗試打印,它拋出這個錯誤:
Field 'product' does not exist in object 'browse_record(product.product, 12)'
(<type 'exceptions.AttributeError'>, AttributeError(KeyError("Field 'product' does not exist in object 'browse_record(product.product, 12)'",),), <traceback object at 0xc2801e4>)
當你真正「拯救」而不是發送到服務器的文檔這通常發生,但我不這樣做,我使用我做的解析器,使用product.product
模型,它應該工作,這是我的解析器:
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'
)
而且我的報告(格式SXW,它有一個.rml版):
[[ repeatIn(objects,'o') ]]
Stock Inventory
Inventory
Date
[[ o.name ]]
[[ formatLang(o.date,date_time=True) ]]
Location
Production Lot
Product
Quantity
[[ repeatIn(o.product, 'p') ]]
[[ p.location_id.name ]]
[[ p.prod_lot_id and p.prod_lot_id.name or '' ]]
[ [[ p.product_id.code ]] ] [[ p.product_id.name ]]
[[ formatLang(p.product_qty) ]] [[ p.product_uom.name ]]
Total:
[[ formatLang(qty_total(o.inventory_line_id)['quantity']) ]] [[ qty_total(o.inventory_line_id)['uom'] ]]
想不通,應該循環上product
我不明白,有什麼想法嗎?
如果您需要進一步的解釋,請讓我知道,謝謝!
非常感謝!看起來非常合乎邏輯,是的,現在就試試吧! – NeoVe 2014-11-06 14:52:12
是的,你說的沒錯,那就是要走的路,然後我會創造一些關係來完成我的工作!非常感謝你! – NeoVe 2014-11-06 16:24:25