user9065581
user9065581

Reputation:

create and open record in inherited tree view is not working in odoo

I am new to odoo. I have inherited res.partner tree view for my custom module but the create and open operations does not work on inherited view.Here is my code plz help.

in my view.xml file.

<record id="my_contacts" model="ir.actions.act_window">
    <field name="name">my contacts</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">res.partner</field>
    <field name="view_mode">tree</field>
    <field name="view_id" ref="base.view_partner_tree"/>
    <field name="search_view_id" ref="base.view_res_partner_filter"/>
    <field name="help" type="html">
      <p class="oe_view_nocontent_create">
        Click to add a new contact.
      </p>
    </field>
</record>

 <record id="my_res_partner_tree" model="ir.ui.view">
<field name="name">res.partner.extended</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_tree"/>
<field name="arch" type="xml">
    <xpath expr="//field[@name='email']" position="after">
        <field name="create_date"/>
        </xpath>
</field>

in my model.py file

class my_contact_template(models.Model):
_inherit = 'res.partner'
_name = 'res.partner'
    _order = "create_date desc"
res_partner()

Upvotes: 2

Views: 580

Answers (1)

Charif DZ
Charif DZ

Reputation: 14751

That is because the Tree view don't support that by default you need to add attribute editable="top" but pay attention to this because it affect the tree view in all action and when you click on the record next time it will not open it in the form view, but instead it will start editing the record in the tree view so you have two option:

1- open the record in two view Tree,Form so you can open the record in The form and edit them.

  <field name="view_mode">tree,form</field>

2- make your tree view editable:

    <field name="arch" type="xml">
        <xpath expr="/tree" position="attributes">
            <attribute name="editable">top</attribute>
        </xpath>

        <xpath expr="//field[@name='email']" position="after">
            <field name="create_date"/>
        </xpath>
    </field>

Upvotes: 1

Related Questions