OpenERP 7 Reports Error

2019-08-29 11:53发布

report.bpl.daily.transaction

(<type 'exceptions.KeyError'>, KeyError(u'report.bpl.daily.transaction',), <traceback object at 0xb1911f04>) 

now I'm going to report generating part.i refer more modules in openerp & created my own code.but above error comes when i clicked print button. my requirement is get all data in bpl.daily.transaction.master table & view them.

please advice me to implement this

here is my bpl_report.py class

class bpl_daily_transaction_report(osv.osv_memory):
    _name = 'bpl.daily.transaction.report'
    _description = 'bpl daily transaction report'
    _columns = {
        'bpl_company_id':fields.many2one('res.company', 'Company', help='Company'),
        'bpl_estate_id':fields.many2one('bpl.estate.n.registration', 'Estate', help='Estate'),
        'bpl_division_id':fields.many2one('bpl.division.n.registration', 'Division', help='Division', domain="[('estate_id','=',bpl_estate_id)]"),
        'date': fields.date('Date', required=True),
    }
    _defaults = {'date': lambda *a: time.strftime('%Y-%m-01'),}

    def print_report(self, cr, uid, ids, context=None):
        datas = {
             'ids': [],
             'model': 'bpl.daily.transaction.master',
             'form': self.read(cr, uid, ids)[0]
        }
        return {
            'type': 'ir.actions.report.xml',
            'report_name': 'bpl.daily.transaction',
            'datas': datas,
        }        
bpl_daily_transaction_report()

and here shows my bpl_report.xml file.seems issue in here.i'm still at beginner level in openerp reporting.

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="daily_transaction_report_action" model="ir.actions.act_window">
    <field name="name">Daily Transaction Report</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">bpl.daily.transaction.report</field>
    <field name="view_type">form</field>
    <field name="view_mode">form,tree</field>
    <field name="target">new</field>
</record>
<record id="daily_transaction_report_view" model="ir.ui.view">
    <field name="name">bpl.daily.transaction.report.form</field>
    <field name="model">bpl.daily.transaction.report</field>
    <field name="arch" type="xml">
    <form string="Daily Transaction Report" version="7.0">
        <field name="bpl_company_id" />
        <field name="bpl_estate_id" />
        <field name="bpl_division_id" />
        <field name="date" />
        <footer>
        <button name="print_report" string="Print" type="object" 
            class="oe_highlight" />
        or
        <button string="Cancel" special="cancel" class="oe_link" />
        </footer>
    </form>
    </field>
</record>

<report id="report_bpl_daily_transaction" string="Daily Transaction"
    model="bpl.daily.transaction.report" name="bpl.daily.transaction"
    auto="False" menu="False" />
<menuitem id="menu_checkroll_reporting" parent="base.menu_reporting"
    name="Checkroll" />
<menuitem id="menu_checkroll_reports" name="Reports"
    parent="menu_checkroll_reporting" />
<menuitem name="Daily Transaction Report" parent="menu_checkroll_reports"
    action="daily_transaction_report_action" id="menu_daily_transaction_report" />
</data>
</openerp>

please help me to sort out this issue.

1条回答
Ridiculous、
2楼-- · 2019-08-29 12:31

From error, it looks like an issue is with report naming convention. service name is wrongly specified by you anywhere. It should be like this:

in module_report.xml --> It should be simple name='bpl.daily.transaction'.

From report.py while parsing, It should be 'report.bpl.daily.transaction' as below:

report_sxw.report_sxw('report.bpl.daily.transaction', 'bpl.daily.transaction', 'RML_PATH_OF_REPORT', parser=PARSER_NAME)

During Printing from wizard, in return, it should 'bpl.daily.transaction' and it seems ok at your end.

Check this at your end and make it proper. It should work.

查看更多
登录 后发表回答