未创建以下视图。有什么问题?
def daily_flash_report_tree(self, cr, uid, ids, context=None):
sql = """
CREATE OR REPLACE VIEW report_view AS (
SELECT
id,name,job
from
sales_summary limit 10
)
"""
cr.execute(sql)
return {
'name': "Daily Flash Report",
'view_type': 'form',
'view_mode': 'tree',
'res_model': 'daliy.flash.report',
'type': 'ir.actions.act_window',
'context': {"search_default_group_period": 1},
}
class daily_flah_report_new(osv.osv):
_name = "daliy.flash.report"
_auto = False
_columns = {
'name': fields.char('Name'),
'job': fields.char('Job'),
}
<record id="drill_flash_report_flash" model="ir.ui.view">
<field name="name">Report</field>
<field name="model">daliy.flash.report</field>
<field name="arch" type="xml">
<tree>
<field name="name" />
<field name="job" />
</tree>
</field>
</record>
<record id="drill_flash_report_action" model="ir.actions.act_window">
<field name="name">Net Revenue</field>
<field name="res_model">daliy.flash.report</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">tree</field>
<field name="context">{"search_default_group_period": 1}</field>
</record>
答案 0 :(得分:1)
请注意您创建了名为&#34; report_view&#34;
的视图CREATE OR REPLACE VIEW report_view AS ( SELECT id,name,job from sales_summary limit 10 )
因为您的对象为daliy.flash.report
所以您的对象的默认表格为daliy_flash_report
_name = "daliy.flash.report" _auto = False
它们不同,您应该确保对象表的名称与视图的名称相同。 解决方案:选择1或2。
daliy_flash_report
的视图
醇>
CREATE OR REPLACE VIEW daliy_flash_report AS ( SELECT id,name,job from sales_summary limit 10 )
_table
来表示表名。祝你好运class daily_flah_report_new(osv.osv): _name = "daliy.flash.report" _auto = False _table = "report_view"