Skip to Content
Menu
This question has been flagged

Hello. I am creating a new module where I will inherit the tree view and form view from the account.invoice module.

So far I've found a lot of examples on how to inherit a form view. As far as i know I should be fine if I edit the my module's view.xml file and just do the following:

<record model="ir.ui.view" id="mymodule.list">
      <field name="name">mymodule list</field>
      <field name="model">mymodule.mymodule</field>
      <field name="inherit_id" ref="account.invoice_tree"/>
      <field name="mode">primary</field>
      <field name="arch" type="xml">
        <tree create="false" edit="false">
                    <field name="partner_id" groups="base.group_user" string="Customer"/>
                    <field name="date_invoice"/>
                    <field name="number"/>
                    ...
        </tree>
      </field>
    </record>

(I would do the same for the form view but with ref="account.invoice_form")


But when i try to do the tree view i get 2 errors.

1 of them regarding the create and delete records

Element '<tree create="false" edit="false">' cannot be located in parent view

The other one asking for partner_id (this one pops up when i delete "create=false" "edit=false" on the tree tag)

Field `partner_id` does not exist

The big picture in here is that. I want to extend fields on account.invoice (1 boolean and the other one string)

Then show the exact same account.invoice tree view on a custom module with the only difference that in this inherited custom tree view I will show those accounts with the boolean set on "true". So what I need right now is to inherit the account.invoice tree and form view, into my custom module. 

Avatar
Discard
Best Answer

When you inherit a View in Odoo, the XML in the arch field is expected to redefine, not define.

Review the documentation at \https://www.odoo.com/documentation/11.0/reference/views.html#inheritance


The error is Odoo's way of telling you - "I looked for a tree node matching create and false the way you list it, but I couldn't find it in the view you are inheriting".

The <tree> node in this case is defining an ANCHOR to which your changes will be made.  After locating the TREE node, you can REPLACE the node, change the ATTRIBUTES of the node, or put something AFTER or BEFORE the node.


Instead of defining tree:

<tree create="false" edit="false">

You redefine tree:

<tree position="replace">
<tree create="false" edit="false">
<field name="..."/>
</tree>
</tree>

or, even better:

<tree position="attributes">
<attribute name="create">false</attribute>
<attribute name="edit">false</attribute>
</tree>

<field name="partner_id" position="after">
<field name="..."/>
</field>
Avatar
Discard
Related Posts Replies Views Activity
1
Sep 23
3581
2
Jul 23
1643
0
Apr 23
1698
2
Jun 22
2746
0
Sep 21
1250