İçereği Atla
Menü
Bu soru işaretlendi
3 Cevaplar
7515 Görünümler


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
Vazgeç
Üretici

Perfect Paresh it works.

Thanks a lot !

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

En İyi Yanıt

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
Vazgeç
Üretici En İyi Yanıt

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
Vazgeç
En İyi Yanıt

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
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Kas 18
5429
1
Kas 24
1577
5
Tem 24
92809
1
Ara 23
3000
2
Mar 23
2244