编辑:用以下内容替换我之前的解决方案,因为这不需要卸载和重新安装:
<record id="report_mypo_test" model="ir.actions.report.xml">
<field name="name">Stock Moves Report</field>
<field name="type">ir.actions.report.xml</field>
<field name="model">stock.move</field>
<field name="report_name">mypo.test</field>
<field name="report_type">aeroo</field>
<field name="in_format">oo-odt</field>
<field name="out_format" model="report.mimetypes" ref="report_aeroo.report_mimetypes_odt_odt"/>
<field name="parser_loc">myaddon/reports/my_parser.py</field>
<field name="report_rml">myaddon/reports/template.odt</field>
<field name="parser_state">loc</field>
<field name="tml_source">file</field>
</record>
<report auto="False" menu="True" id="report_mypo_test" model="stock.move"
name="mypo.test" rml="myaddon/reports/template.odt" string="Stock Moves Report"/>
my_parser.py:
import time
from tools.translate import _
from report import report_sxw
from report.report_sxw import rml_parse
from osv import fields, osv
import netsvc
class Parser(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(Parser, self).__init__(cr, uid, name, context)
ids = self.pool.get('stock.move').search(self.cr, self.uid, [], context=context)
self.stockmoves = self.pool.get('stock.move').browse(self.cr, self.uid, ids)
self.localcontext.update({
'stockmoves': self.stockmoves
})
感谢全能的上帝,以及许多在互联网上贡献自己作品的人。