When I click on the button I should see a list. There should also be the ability to create a new record. But when I click on the button I get:
No default view of type ' form' could be found!
How to fix it?
If I go from the main menu, then there is no such problem
<?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>
It seems you have given white space in "view_mode" values. No need to give space between values.
Try with following code:
<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>
EDIT:
Remove <field name="target">new</field>
line.
Documentation:
view_mode
comma-separated list of view types as a string (/!\ No spaces /!). All of these types will be present in the generated views list (with at least a False view_id)