(<type 'exceptions.KeyError'>, KeyError('report',), <traceback object at 0x7fa426cf8e60>) 自定义 Qweb 报告 odoo 10

(<type 'exceptions.KeyError'>, KeyError('report',), <traceback object at 0x7fa426cf8e60>) Custom Qweb report odoo 10

我在制作自定义报告时遇到问题,我一直在创建名称为 mantto_app

的模块

mantto_app/views/mantto_view.xml:

<?xml version="1.0"?> 
 <odoo> 
<record id="view_form_mantto_task" model="ir.ui.view"> 
<field name="nomEquipo">Mantto Task Form</field> 
<field name="model">mantto.task</field> 
<field name="arch" type="xml"> 

<form string="Mantto Task"> 
<sheet>
    <group name="group_top" >
    <group name="group_left">
      <field name="nomEquipo"/>
      <field name="marca"/>
      <field name="modelo"/>
      </group>
      <group name="group_right">
      <field name="serie"/>
      <field name="unidad"/>
      <field name="is_done"/>
      </group>
      </group> 
      <group name="group_buttom">
      <field name="fecha"/>
      <field name="obs"/>
      <field name="vb"/>
     <!-- <field name="dxPre1"/>-->

      </group>
</sheet>   
  </form>
</field> 
</record>
<record id="view_tree_mantto_task" model="ir.ui.view">
  <field name="nomEquipo">Mantto Task Tree</field>
  <field name="model">mantto.task</field>
  <field name="arch" type="xml">
    <tree colors="decoration-muted:is_done==True">
      <field name="nomEquipo"/>
      <field name="is_done"/>
      <field name="unidad"/>
    </tree>
  </field>
</record>

<record id="view_filter_mantto_task" model="ir.ui.view">
<field name="name">Mantto Task Filter</field>
<field name="model">mantto.task</field>
<field name="arch" type="xml">

<search>
<field name="nomEquipo"/>
<filter string="Not Done" domain="[('is_done','=',False)]"/>
<filter string="Done" domain="[('is_done','!=',False)]"/>
</search>

</field>
</record>

</odoo> 

mantto_app/views/mantto_menu.xml:

<?xml version="1.0"?> 
<odoo> 
<!-- Action to open To-do Task list --> 
<act_window id="action_mantto_task" 
name="Mantto Task" 
res_model="mantto.task" 
view_mode="tree,form" /> 
<!-- Menu item to open To-do Task list --> 
<menuitem id="menu_mantto_task" 
name="Mantto" 
action="action_mantto_task" /> 
</odoo> 

并且我已经创建了一个模块来生成包含以下内容的报告

mantto_report/reports/mantto_report.xml:

<?xml version="1.0"?> 
<odoo> 
<report id="action_mantto_task_report" 
string="Mantto Tasks" 
model="mantto.task" 
report_type="qweb-html" 
name="mantto_report.report_mantto_task_template"
/> 
<template id="report_mantto_task_template"> 
<t t-call="report.html_container"> 
<t t-call="report.external_layout"> 
  <div class="page"> 
    <!-- Report page content --> 
  </div> 
</t> 
</t> 
</template> 
</odoo> 

初始化.py

清单.py

{  
'name': 'Mantto Report', 
'description': 'Report for Mantto tasks.', 
'author': 'EC', 
'depends': ['mantto_app'], 
'data': ['reports/mantto_report.xml'] 
}      

但是我给按钮打印和选择时总是抛出这个错误

   2017-12-19 14:34:43,106 2412 ERROR todo odoo.service.report: Exception: 'report'
   Traceback (most recent call last):
   File "/home/odoo/odoo-dev/odoo/odoo/service/report.py", line 94, in go
   result, format = odoo.report.render_report(cr, uid, ids, object, datas, 
   context)
   File "/home/odoo/odoo-dev/odoo/odoo/report/__init__.py", line 19, in 
   render_report
   return env['ir.actions.report.xml'].render_report(ids, name, data)
   File "/home/odoo/odoo-dev/odoo/odoo/addons/base/ir/ir_actions.py", line 
   232, in render_report
   return self.env['report'].get_pdf(res_ids, report, data=data), 'pdf'
   File "/home/odoo/odoo-dev/odoo/odoo/api.py", line 760, in __getitem__
   return self.registry[model_name]._browse((), self)
   File "/home/odoo/odoo-dev/odoo/odoo/modules/registry.py", line 174, in 
   __getitem__
   return self.models[model_name]
   KeyError: 'report'
   2017-12-19 14:34:43,358 2412 ERROR todo odoo.addons.web.controllers.main: 
   An exception occured during an http request
   Traceback (most recent call last):
   File "/home/odoo/odoo-dev/odoo/addons/web/controllers/main.py", line 70, 
   in wrap
   return f(*args, **kwargs)
   File "/home/odoo/odoo-dev/odoo/addons/web/controllers/main.py", line 
   1480, in index
   request.session.db, request.session.uid, request.session.password, 
   report_id])
   File "/home/odoo/odoo-dev/odoo/odoo/http.py", line 118, in dispatch_rpc
   result = dispatch(method, params)
   File "/home/odoo/odoo-dev/odoo/odoo/service/report.py", line 35, in 
   dispatch
   res = fn(db, uid, *params)
   File "/home/odoo/odoo-dev/odoo/odoo/service/report.py", line 142, in 
   exp_report_get
   return _check_report(report_id)
   File "/home/odoo/odoo-dev/odoo/odoo/service/report.py", line 120, in 
   _check_report
   raise UserError('%s: %s' % (exc.message, exc.traceback))
   UserError: (u"report: (<type 'exceptions.KeyError'>, KeyError('report',), 
   <traceback object at 0x7fa426cf8e60>)", '')
   2017-12-19 14:34:43,379 2412 INFO todo werkzeug: 10.10.10.94 - - 
   [19/Dec/2017 
   14:34:43] "POST /web/report HTTP/1.1" 50 -

有人知道原因吗,先谢谢了

Ubuntu 服务器 16.04 wkhtmltopdf 0.12.1(带有修补的 qt) 奥多 10

如您在错误中所见

return self.models[model_name]
   KeyError: 'report'

因此请尝试将 'report' 添加到您的依赖项中:

{  
    'name': 'Mantto Report', 
    'description': 'Report for Mantto tasks.', 
    'author': 'EC', 
    'depends': ['mantto_app', 'report'], 
    'data': ['reports/mantto_report.xml'] 
}