Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
3321 Widoki

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!

Awatar
Odrzuć
Autor

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

Najlepsza odpowiedź
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>
Awatar
Odrzuć
Autor

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

Powiązane posty Odpowiedzi Widoki Czynność
View inheritance Rozwiązane
1
mar 20
3441
12
gru 18
34765
1
lip 16
7070
0
kwi 16
3211
2
mar 15
5916