Skip to Content
Menu
This question has been flagged
3 Replies
6308 Views


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


Avatar
Discard
Author

Perfect Paresh it works.

Thanks a lot !

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

Best Answer

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>
Avatar
Discard
Author Best Answer

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

Avatar
Discard
Best Answer

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

Avatar
Discard
Related Posts Replies Views Activity
1
Nov 18
4418
1
Nov 24
100
5
Jul 24
86782
1
Dec 23
1811
2
Mar 23
1319