跳至内容
菜单
此问题已终结
2 回复
3322 查看

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!

形象
丢弃
编写者

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

最佳答案
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>
形象
丢弃
编写者

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

相关帖文 回复 查看 活动
1
3月 20
3442
12
12月 18
34766
1
7月 16
7070
0
4月 16
3211
2
3月 15
5916