Skip to Content
Menu
This question has been flagged
2 Replies
2423 Views

This question is slightly related to \a previous one I asked, except I believe I found a way to do what I want (which answers the previous question). I am trying to combine multiple models into the same view, and according to the docs, this forum, stackoverflow and random websites, what I want is to inherit the main view and use an xpath to insert my fields.

My main view is this

<record model="ir.ui.view" id="erpwarehouse.mainviewrec">
 <field name="name">erpwarehouse.form</field>
 <field name="model">erpwarehouse.erpwarehouse</field>
 <field name="arch" type="xml">
 <form string="Test">
 <sheet>
 <notebook colspan="6">
 <page string="ERPWarehouse" name="erpwarehouse" autofocus="autofocus">
 <label for="estimate_id">estimate_id</label> <field name="estimate_id"/>
 <label for="worder_id">worder_id</label> <field name="worder_id"/>
 <label for="receiving_id">receiving_id</label> <field name="receiving_id"/>
 <label for="production_id">production_id</label> <field name="production_id"/>
 <label for="billing_id">billing_id</label> <field name="billing_id"/>
 </page>
 </notebook>
 </sheet>
 </form>
 </field>
</record>

I have tried the following possible solutions to try to get my other views to show up as extra pages in the notebook defined above (one for each of the fields) to no avail.

<record model="ir.ui.view" id="erpwarehouse.estimateView">
 <field name="name">erpwarehouse.estimateform</field>
 <field name="model">erpwarehouse.estimate</field>
 <field name="inherit_id" ref="erpwarehouse.mainviewrec"/>
 <field name="arch" type="xml">
 <xpath expr="//notebook/page[@name='erpwarehouse']" position="before">
 <page string="Estimate">
 <field name="project_scope"/>
</page>
 </xpath>
 </field>
</record>
<record model="ir.ui.view" id="erpwarehouse.estimateView">
 <field name="name">erpwarehouse.estimateform</field>
 <field name="model">erpwarehouse.estimate</field>
 <field name="inherit_id" ref="erpwarehouse.mainviewrec"/>
 <field name="arch" type="xml">
 <notebook position="inside">
 <page string="Estimate">
 <field name="project_scope"/>
 </page>
 </notebook>
 </field>
</record>
<record model="ir.ui.view" id="erpwarehouse.estimateView">
 <field name="name">erpwarehouse.estimateform</field>
 <field name="model">erpwarehouse.estimate</field>
 <field name="inherit_id" ref="erpwarehouse.mainviewrec"/>
 <field name="arch" type="xml">
 <xpath expr="//page[0]" position="before">
 <page string="Estimate">
 <field name="project_scope"/>
</page>
 </xpath>
 </field>
</record>

I have also changed the id and name of the record to be erpwarehouse.mainviewrec_inherit, but that did not appear to do anything. Am I missing something? Any help would be greatly appreciated!

Avatar
Discard
Author

I am also not getting any errors in the odoo log, my browser's console, or popups. The xpath page simply does not appear. Inside the backend, I can see that the inherit relationship is working as settings->User Interface->Views->erpwarehouse.form->inherited views shows erpwarehouse.estimateform as well as the external ID that I set

Best Answer
Hi ,
Try this way

<record model="ir.ui.view" id="erpwarehouse.estimateView">
<field name="name">erpwarehouse.estimateform</field>
<field name="model">erpwarehouse.estimate</field>
<field name="inherit_id" ref="erpwarehouse.mainviewrec"/>
<field name="arch" type="xml">
    <page string="ERPWarehouse" position="before">
        <page string="Estimate">
            <field name="project_scope"/>
        </page>
    </page>
</field>
</record>
Avatar
Discard
Author

I just tried this way and unfortunately it did not work. I got the error "View inheritance may not use attribute 'string' as a selector.". That led me to replace string="ERPWarehouse" with name="erpwarehouse" and I didn't get an error, but I'm back where I started

Related Posts Replies Views Activity
1
Mar 20
1993
12
Dec 18
32533
1
Jul 16
5609
0
Apr 16
2582
2
Mar 15
4604