当我单击按钮时,我应该看到一个列表。还应该有创造新记录的能力。但是当我点击按钮时我得到:
找不到“表单”类型的默认视图!
如何解决?
如果我从主菜单进入,就没有这样的问题
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<act_window
id="attach_pdf_action"
name="Attach PDF"
res_model="attach.pdf" />
<menuitem
id="attach_pdf_menu"
name="Attach PDF"
action="attach_pdf_action"
parent=""
sequence="5" />
<record id="attach_pdf_view_form" model="ir.ui.view">
<field name="name">Attach PDF Form</field>
<field name="model">attach.pdf</field>
<field name="arch" type="xml">
<form>
<group>
<field name="product_id"/>
<field name="product_attribute_value_id"/>
</group>
<group>
<field name="file" widget="binary" filename="file_name" string="Binary"/>
</group>
</form>
</field>
</record>
<record id="attach_pdf_view_tree" model="ir.ui.view">
<field name="name">Attach PDF List</field>
<field name="model">attach.pdf</field>
<field name="arch" type="xml">
<tree>
<field name="product_id"/>
<field name="product_attribute_value_id"/>
<field name="file_name" readonly="1"/>
</tree>
</field>
</record>
<record id="attach_pdf_view_search" model="ir.ui.view">
<field name="name">Attach PDF Search</field>
<field name="model">attach.pdf</field>
<field name="arch" type="xml">
<search>
<field name="product_id"/>
<field name="product_attribute_value_id"/>
</search>
</field>
</record>
<record id="attach_file_wizard" model="ir.actions.act_window">
<field name="name">Attach PDF</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">attach.pdf</field>
<field name="view_type">form</field>
<field name="view_mode">tree, form</field>
<field name="domain" > [('product_id', '=', context.get('product_name'))]</field>
<field name="view_id" ref="attach_pdf_view_tree"/>
<field name="target">new</field>
</record>
<record id="view_form_product_attr_pdf" model="ir.ui.view">
<field name="name">attach_pdf_attribute_product_product_template_only_form_view</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<xpath expr="//header/button[@name='121']" position="after">
<button name="%(attach_pdf_attribute.attach_file_wizard)d" context="{'product_name': name}" string="Attach PDF" type="action" class="oe_highlight"/>
</xpath>
</field>
</record>
</data>
</odoo>
您似乎在“view_mode”值中给出了空格。无需在值之间留出空格。
尝试使用以下代码:
<record id="attach_file_wizard" model="ir.actions.act_window">
<field name="name">Attach PDF</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">attach.pdf</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain" > [('product_id', '=', context.get('product_name'))]</field>
<field name="view_id" ref="attach_pdf_view_tree"/>
</record>
编辑:
删除
<field name="target">new</field>
线。
文档:
查看模式
以逗号分隔的视图类型列表作为字符串(/!\ 无空格/!)。所有这些类型都将出现在生成的视图列表中(至少有一个 False view_id)
删除“form”之前的空格 树,形式