Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
3 Replies
7509 Tampilan


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

Perfect Paresh it works.

Thanks a lot !

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

Jawaban Terbai

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

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

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
Buang
Post Terkait Replies Tampilan Aktivitas
1
Nov 18
5429
1
Nov 24
1571
5
Jul 24
92805
1
Des 23
2998
2
Mar 23
2244