跳至內容
選單
此問題已被標幟
3 回覆
7520 瀏覽次數


Hi .
I want to create a view to move fields in sale view .
I have plenty of modules which modify the product view in sales.
I would like my custom view will be all the time the last to modify the product view is it possible?

For example i want to hide a page (variants) but when i do that : 


<record id="product_template_inherited_variants_repalce_form2" model="ir.ui.view">
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<xpath expr="//notebook/page[@name='variants']" position="replace"/>
</field>
</record>

A module after need this page to add things so i have an error : 

ValueError: Element '<field name="attribute_line_ids">' cannot be located in parent view

So the best thing is to be the last for modifying this view. Is it possible to define that? 
I can t inherit of all module , because i will add new modules soon for sure :( 

Thanks a lot for your answer


頭像
捨棄
作者

Perfect Paresh it works.

Thanks a lot !

Great. Please click the check mark next to the answer to mark it as resolved.

最佳答案

Hi Thomas:

You can define an attribute called "priority" in the view definition to control the sequence in which the views are applied. The default priority is set at 16. Try setting it to 100 so your custom view definition is applied after all the other views. To expand on your example, try this.

<record id="product_template_inherited_variants_repalce_form2" model="ir.ui.view">
<field name="model">product.template</field>
    <field name="inherit_id" ref="product.product_template_only_form_view"/>
    <field name="priority">100</field>
    <field name="arch" type="xml">
<xpath expr="//notebook/page[@name='variants']" position="replace"/>
</field>
</record>
頭像
捨棄
作者 最佳答案

Thanks ​Rajkumar Murugan
Yes i can do this , but infact my question is more general.
Is it possible to say : This view is the last inherit of an inital view.
I want all modules do things in the inital view before my view ​
Is it possible?
Like to define a sequence of something like that? :)

Thnaks a lot

頭像
捨棄
最佳答案

Hi thomas,

If you want to hide a page variants, you have to use position as attributes. For eg. see below code

<record id="product_template_inherited_variants_repalce_form2" model="ir.ui.view">
    <field name="model">product.template</field>
    <field name="inherit_id" ref="product.product_template_only_form_view"/>
    <field name="arch" type="xml">
        <xpath expr="//notebook/page[@name='variants']" position="attributes"/>
            <attribute name="invisible">0</attribute>
    </field>
</record>

For further information about view inheritance, click this link 

http://learnopenerp.blogspot.com/2018/01/inheritance-in-models-and-views.html

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
11月 18
5430
1
11月 24
1583
5
7月 24
92830
1
12月 23
3013
2
3月 23
2244