Odoo10 ProgrammingError:pivot-table中不存在列id

时间:2018-05-07 03:47:19

标签: pivot pivot-table odoo odoo-10

当点击菜单打开枢轴视图时,我一直遇到错误"编程错误:列new_table_report.id不存在"。

我的代码文件.py:

@api.model_cr
def init(self):
    tools.drop_view_if_exists(self._cr, 'new_table_report')
    self._cr.execute("""
          CREATE or REPLACE VIEW new_table_report AS (
              SELECT  sub.*, 
                      (SELECT name FROM maintenance_rating_score_range WHERE 
                         (sub.average_deviation >= from_score and 
                          sub.average_deviation <= to_score)
                       ) as rating
              FROM(
                   SELECT  
                      eq.id as equipment_id,
                      eq.name as name,
                      eq.category_id as category_id,
                      eq.partner_id as partner_id,
                      count(m.id) as number_service,
                      (sum(rs.score)/count(m.id)) as average_deviation
                   FROM maintenance_request m
                     INNER JOIN maintenance_equipment eq on (m.equipment_id = eq.id)
                     INNER JOIN maintenance_rating r on (r.request_id = m.id)
                     LEFT JOIN maintenance_rating_score rs on (r.rating_satisf_id = rs.id)
                  GROUP BY eq.id, eq.partner_id
              )AS sub 
         )
    """)

我的代码文件.xml:

<record model="ir.ui.view" id="view_new_table_report_pivot">
    <field name="name">new.table.report.pivot</field>
    <field name="model">new.table.report</field>
    <field name="arch" type="xml">
        <pivot string="Report Analysis" disable_linking="False">
            <field name="equipment_id" type="row"/>
            <field name="number_service" type="measure"/>
            <field name="average_deviation" type="measure"/>
        </pivot>
    </field>
</record>

<record model="ir.actions.act_window" id="action_new_tabke_report">
    <field name="name">Report Analysis</field>
    <field name="res_model">new.table.report</field>
    <field name="view_type">form</field>
    <field name="view_mode">pivot,graph</field>
    <field name="context">{}</field>
</record>

感谢您前进。

1 个答案:

答案 0 :(得分:-2)

我可以这样做,我不在新表格报告中创建id字段