2

I'm trying to put inside res.partner's formview notebook a new tab, with a treeview with a list of related objects (a "Scheduling" model implemented by me that has a Many2one pointing to res.partner).

I can't find a way to do it, googling it didn't help much. How do I point this treeview to the existing one for my model? And how to specify the domain so only the correct data is shown?]

the current code for the res.partner form is

<odoo>
    <data>
        <record model="ir.ui.view" id="partner_form">
            <field name="name">res.partner.form</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_form"/>
            <field name="arch" type="xml">
                <xpath expr="//notebook/page[3]" position="attributes">
                    <attribute name="invisible">1</attribute>
                </xpath>
                <xpath expr="//notebook/page[3]" position="after">
                    <page string='Consultas'>
                    </page>
                </xpath>
            </field>
        </record>
    </data>
</odoo>
forvas
  • 9,801
  • 7
  • 62
  • 158
Marcio Cruz
  • 2,012
  • 1
  • 23
  • 30

1 Answers1

5

If I have understood you well, you have made your tree view in other part of your code and now you want to see this tree view in a new page in the notebook of res.partner form, don't you?

So if in Scheduling model you have a Many2one pointing to res.partner, in this case you should have a One2many in res.partner pointing to Scheduling model (with the respective inverse_name). Imagine that the name of the One2many is schedules, and your Scheduling tree view is named view_scheduling_tree:

<odoo>
    <data>
        <record model="ir.ui.view" id="partner_form">
            <field name="name">res.partner.form</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_form"/>
            <field name="arch" type="xml">
                <xpath expr="//notebook/page[3]" position="attributes">
                    <attribute name="invisible">1</attribute>
                </xpath>
                <xpath expr="//notebook/page[3]" position="after">
                    <page string='Consultas'>
                        <field name="schedules" context="{'tree_view_ref': 'your_module.view_scheduling_tree'}"/>
                    </page>
                </xpath>
            </field>
        </record>
    </data>
</odoo>
forvas
  • 9,801
  • 7
  • 62
  • 158
  • Thanks. The context is key here. Otherwise, it just shows only one field like 'name' or so. – Dat TT May 23 '23 at 12:51