I have a button in form view that inherited base.view_partner_form and when I clicked this button, I want to show tree view in another model.I try to create but External ID not found error is appeared.How can I fix it?Thank YouHere is my code.
in .xml file
<!--Create button-->
<record id="similar_list_view_partner_form" model="ir.ui.view">
<field name="name">similar_list_view_partner_form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"></field>
<field name="arch" type="xml">
<xpath expr="//button[@name='toggle_active'][not(ancestor::field)]" position="after">
<button class="oe_stat_button" name="similar_list_button_action" type="object" icon="fa-align-justify"> <field name="show" readonly="1"/> </button>
</xpath>
</field>
</record>
<!--Create Tree View with three fields-->
<record id="similar_detail_tree_view" model="ir.ui.view">
<field name="name">Similar Detail Tree View</field>
<field name="model">similar.task</field>
<field name="arch" type="xml">
<tree>
<field name="similar_name"/>
<field name="similar_email"/>
<field name="similar_phone"/>
</tree>
</field>
</record>
In .py file
#function called by button to show tree view
class similar_contact(models.Model):
_inherit= 'res.partner'
show=fields.Char("Similar")
@api.multi
def similar_list_button_action(self):
tree_view_id=self.env.ref('similar_task.similar_detail_tree_view').id
return {
'name':'Similar Detail Tree View',
'type':'ir.actions.act_window',
'res_model':'similar.task',
'view_mode':'tree',
'views':[(view_tree_id,'tree')],
'res_id':False,
'target':'new'
}
#New model
class similar_detail(models.Model):
_name="similar.task"
similar_name=fields.Char("Name")
similar_email=fields.Char("Email")
similar_phone=fields.Char("Phone")
Hello SuDarLy try this may be its helpful.
http://learnopenerp.blogspot.com/2017/10/redirect-to-tree-view-from-button-click.html