Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
3210 Tampilan

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
Buang
Penulis

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

Jawaban Terbai
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
Buang
Penulis

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

Post Terkait Replies Tampilan Aktivitas
View inheritance Diselesaikan
1
Mar 20
3304
12
Des 18
34494
1
Jul 16
6879
0
Apr 16
3125
2
Mar 15
5760